/* Сервис ввода данных Систематики — мобильный слой (адаптив того же приложения).
   Подключается ПОСЛЕ mockup.css. Все правила скоупом до телефона (≤720px),
   кроме скрытия нижней панели/шторки на десктопе. Статичные мокапы 01-13 не затрагивает. */

/* ---- элементы, которых нет на десктопе ---- */
.mnav{display:none}
.mlist{display:none}
.mfilter-btn{display:none}
.sheet-scrim{align-items:flex-end!important}

@media (max-width:900px){

  /* ---- каркас: убираем боковое меню, одна колонка ---- */
  .app{grid-template-columns:1fr;min-height:100dvh}
  .sidebar{display:none}
  .corner{display:none}

  /* ---- верхняя панель раздела: липкая, компактнее ---- */
  .topbar{position:sticky;top:0;z-index:30;padding:13px 16px;gap:10px}
  .topbar h2{font-size:17px}
  .topbar .crumb{font-size:11px}
  .topbar .right{flex:none}
  .topbar .btn-primary{padding:0 14px}

  /* контент: место под нижнюю панель + комфортные поля */
  .content{padding:16px 14px 92px;gap:16px}

  /* ---- показатели: 2 в ряд ---- */
  .section-grid.sg-3,.section-grid.sg-4{grid-template-columns:1fr 1fr;gap:10px}
  .kpi-card{padding:13px 14px;border-radius:var(--r-sm)}
  .kpi-card .val{font-size:21px}
  .kpi-card .kpi-ico{width:26px;height:26px}

  /* ---- панель/фильтры (фильтры в «спойлер») ---- */
  .panel{border-radius:var(--r-sm);overflow:visible}
  .mfilter-btn{
    display:flex;align-items:center;justify-content:space-between;width:100%;
    background:none;border:none;border-bottom:1px solid var(--border-2);
    padding:13px 16px;font:inherit;font-weight:600;font-size:13.5px;color:var(--ink);cursor:pointer;
  }
  .mfilter-btn>span{display:inline-flex;align-items:center;gap:8px}
  .mfilter-btn .ico{width:18px;height:18px;color:var(--ink-3)}
  .mf-badge{display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:var(--accent-ink);color:#fff;font-size:11px;font-weight:700}
  .mf-chev{display:flex;color:var(--ink-3);transition:transform var(--dur-fast) var(--ease)}
  .mf-chev .ico{width:18px;height:18px}
  .panel.filters-open .mf-chev{transform:rotate(90deg)}
  .panel .panel-tools{display:none;padding:12px 12px}
  .panel.filters-open .panel-tools{display:flex}
  .fl{min-width:0;flex:1 1 130px}
  .panel-tools .btn-ghost{flex:1 1 100%;justify-content:flex-start;margin-left:0!important;padding:4px 2px}

  /* ---- широкие таблицы прячем, показываем компактный список (.mlist) ---- */
  .panel table{display:none}
  .mlist{display:block}
  .mitem{
    display:flex;align-items:center;gap:12px;width:100%;text-align:left;
    background:none;border:none;border-bottom:1px solid var(--border-2);
    padding:13px 16px;cursor:pointer;font:inherit;color:inherit;
  }
  .mitem:last-child{border-bottom:none}
  .mitem:active{background:var(--panel-2)}
  .mitem-main{flex:1;min-width:0}
  .mitem-title{font-size:14px;color:var(--ink);font-weight:600;line-height:1.35}
  .mitem-title .co{font-weight:600}
  .mitem-title .sub-2{font-weight:400;color:var(--ink-2)}
  .mitem-title .tag{vertical-align:middle}
  .mitem-sub{font-size:12px;color:var(--ink-2);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .mitem-end{display:flex;align-items:center;gap:7px;flex:none;color:var(--ink-3);max-width:46%}
  .mitem-end .num{font-size:13px}
  .mitem-chev{display:flex;color:var(--ink-3)}
  .mitem-chev .ico{width:18px;height:18px}
  .mlist-empty{padding:34px 18px;text-align:center;color:var(--ink-3);font-size:13.5px}

  /* ---- модалки → нижние «шторки», прибиты к нижнему краю (поверх нижней панели) ---- */
  .scrim{align-items:flex-end;z-index:80}
  .scrim>.modal{
    position:fixed;left:0;right:0;bottom:0;
    width:auto!important;max-width:none;border-radius:var(--r) var(--r) 0 0;
    max-height:92dvh;animation:sheet-up .26s var(--ease);
  }
  .scrim>.modal::before{
    content:"";position:absolute;top:9px;left:50%;transform:translateX(-50%);
    width:40px;height:4px;border-radius:999px;background:var(--border);z-index:2;
  }
  .modal-head{padding:22px 18px 16px}
  .modal-body{padding:18px 18px;max-height:62dvh}
  .modal-foot{padding:13px 18px calc(15px + env(safe-area-inset-bottom))}
  .modal-foot .btn-primary,.modal-foot .btn-s{flex:1;justify-content:center;min-height:46px}
  .row-2{grid-template-columns:1fr;gap:0}
  .row-2 .field{margin-bottom:15px}
  .seg{display:flex} .seg .opt{flex:1;text-align:center;padding:9px 8px}

  /* ---- вход ---- */
  .login-wrap .modal{width:min(392px,92vw)!important}
  .login-wrap .modal-body{padding:28px 22px!important}

  /* кнопки крупнее под палец */
  .btn-primary,.btn-s{min-height:44px}

  /* импорт на телефоне */
  .imp-map{grid-template-columns:1fr;gap:9px}
  .imp-map-f{min-width:84px}
  .imp-seg .opt{padding:9px 6px;font-size:12px}
}

/* ---- нижняя панель вкладок (только мобильный) ---- */
@media (max-width:900px){
  .mnav{
    display:flex;position:fixed;left:0;right:0;bottom:0;z-index:40;
    background:var(--panel);border-top:1px solid var(--border);
    padding-bottom:env(safe-area-inset-bottom);
    box-shadow:0 -2px 14px rgba(20,35,58,.07);
  }
  .mnav-item{
    flex:1;min-width:0;background:none;border:none;font:inherit;cursor:pointer;
    display:flex;flex-direction:column;align-items:center;gap:3px;
    padding:9px 4px 7px;color:var(--ink-3);font-weight:600;
    transition:color var(--dur-fast) var(--ease);
  }
  .mnav-item .ico{width:22px;height:22px}
  .mnav-item span{
    font-size:10.5px;letter-spacing:.1px;max-width:100%;
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  }
  .mnav-item.active{color:var(--accent-ink)}
  .mnav-item.active .ico{stroke-width:2}
  .mnav-item:active{background:var(--panel-2)}
  .mnav-item.running{position:relative}
  .mnav-item.running::after{content:"";position:absolute;top:6px;left:calc(50% + 7px);width:7px;height:7px;border-radius:50%;background:var(--bad);animation:tmr-pulse 1.6s infinite}
}

/* ---- выезжающая шторка «Ещё» (прибита к нижнему краю) ---- */
.sheet{
  position:fixed;left:0;right:0;bottom:0;
  background:var(--panel);border-radius:var(--r) var(--r) 0 0;
  padding:10px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow:var(--e3);animation:sheet-up .26s var(--ease);max-height:88dvh;overflow:auto;
}
.sheet-grip{width:40px;height:4px;border-radius:999px;background:var(--border);margin:2px auto 14px}
.sheet-acct{display:flex;align-items:center;gap:12px;padding:4px 4px 14px;border-bottom:1px solid var(--border-2);margin-bottom:6px}
.sheet-acct .nm{font-weight:700;font-size:14.5px;line-height:1.3}
.sheet-acct .rl{font-size:12px;color:var(--ink-2)}
.sheet .nav-cap{padding:9px 6px 5px}
.sheet .nav-item{padding:12px 10px;font-size:14.5px;margin-bottom:2px}
.sheet .nav-item.active::before{left:-16px}
.sheet-act{
  display:flex;align-items:center;gap:9px;width:100%;
  background:var(--panel-2);border:1px solid var(--border);border-radius:12px;
  padding:14px 14px;margin-top:8px;font:inherit;font-weight:600;font-size:14px;
  color:var(--ink);cursor:pointer;min-height:48px;
}
.sheet-act:active{background:var(--border-2)}
.sheet-act.danger{color:var(--bad);border-color:var(--bad-soft)}

/* ---- окно деталей записи (по тапу на пункт списка) ---- */
.dlist{display:flex;flex-direction:column}
.drow{display:flex;justify-content:space-between;align-items:baseline;gap:18px;padding:11px 0;border-bottom:1px solid var(--border-2)}
.drow:last-child{border-bottom:none}
.dl{font-size:12.5px;font-weight:600;color:var(--ink-2);flex:none}
.dv{text-align:right;font-size:14px;font-weight:500;min-width:0}
.dv .co{font-weight:600}
.drm-del{margin-right:auto;color:var(--bad)!important;border-color:var(--bad-soft)!important}

@keyframes sheet-up{from{transform:translateY(100%)}to{transform:translateY(0)}}
@media (prefers-reduced-motion:reduce){
  .scrim>.modal,.sheet{animation:none}
}
