/* ===== v16.74 Mobile UI ===== */
.mobile-topbar, .mobile-more-overlay{display:none}

@media (max-width:768px){
  html,body{max-width:100%;overflow-x:hidden}
  body{padding-bottom:74px}
  header{
    position:sticky;
    top:0;
    z-index:1200;
    width:100%;
    max-width:100%;
    overflow:visible;
  }

  /* Скрываем десктопную перегруженную шапку на мобильном */
  header > *:not(.mobile-topbar){display:none!important}

  .mobile-topbar{
    display:block;
    background:#fff;
    border-bottom:1px solid #e5e9ef;
    padding:10px 12px 8px;
    width:100%;
    box-sizing:border-box;
  }
  .mobile-topbar-main{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
  }
  .mobile-brand{
    font-size:20px;
    font-weight:800;
    white-space:nowrap;
  }
  .mobile-menu-button{
    width:44px;
    height:40px;
    border:1px solid #dce3eb;
    border-radius:12px;
    background:#f7f9fc;
    font-size:22px;
    line-height:1;
  }
  .mobile-save-status{
    margin-top:4px;
    font-size:11px;
    color:#7b8794;
    min-height:16px;
  }

  aside{display:none!important}
  main{
    width:100%!important;
    max-width:100%!important;
    margin:0!important;
    padding:12px!important;
    box-sizing:border-box;
    overflow-x:hidden!important;
  }

  .view{max-width:100%;overflow-x:hidden}
  .section-title{
    display:flex;
    flex-direction:column;
    align-items:stretch!important;
    gap:10px;
  }
  .section-title > *{min-width:0}
  .section-title button{width:100%}

  .ai-main-create-btn{
    width:100%!important;
    min-height:48px;
    font-size:15px;
    border-radius:14px;
  }

  .card{
    width:100%;
    max-width:100%;
    box-sizing:border-box;
    overflow:hidden;
  }

  .form-grid{
    grid-template-columns:1fr!important;
  }

  /* Кнопки внутри карточек не должны создавать горизонтальный скролл */
  .card button,
  .card .btn,
  .card .btn-light{
    max-width:100%;
  }

  /* v22.18: глобальный перенос inline-flex удалён; перенос задаётся только целевым компонентам. */

  /* Таблицы превращаем в карточки строк там, где это безопасно */
  

  /* Сравнение тарифов на мобильном — без горизонтального скролла */
  .tariff-table-wrap{
    overflow:visible!important;
  }
  .tariff-table{
    min-width:0!important;
    width:100%!important;
    table-layout:fixed;
    font-size:11px;
  }
  .tariff-table th,.tariff-table td{
    padding:8px 4px!important;
    word-break:break-word;
  }
  .tariff-table th:first-child,.tariff-table td:first-child{
    width:43%;
  }

  .subscription-grid{
    grid-template-columns:1fr!important;
  }
  .subscription-card{
    min-height:auto!important;
  }

  
  
  
  

  .mobile-more-overlay{
    position:fixed;
    inset:0;
    z-index:1600;
    background:rgba(17,24,39,.38);
    align-items:flex-end;
    justify-content:center;
  }
  .mobile-more-overlay.open{display:flex}
  .mobile-more-sheet{
    width:100%;
    max-height:80vh;
    overflow-y:auto;
    background:#fff;
    border-radius:22px 22px 0 0;
    padding:8px 14px calc(18px + env(safe-area-inset-bottom));
    box-sizing:border-box;
    box-shadow:0 -14px 40px rgba(0,0,0,.14);
  }
  .mobile-sheet-handle{
    width:42px;height:4px;background:#d6dce3;border-radius:999px;margin:2px auto 12px;
  }
  .mobile-sheet-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom:14px;
  }
  .mobile-sheet-title{font-size:22px;font-weight:800}
  .mobile-sheet-close{
    width:40px;height:40px;border:0;border-radius:12px;background:#f1f4f7;font-size:26px;
  }
  .mobile-menu-grid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
  }
  .mobile-menu-grid button{
    border:1px solid #e1e6ec;
    background:#f8fafc;
    border-radius:14px;
    min-height:54px;
    padding:10px;
    font-size:14px;
    font-weight:700;
    text-align:left;
  }

  body.mobile-more-open{overflow:hidden!important}

  /* Модальные окна */
  .overlay{max-width:100vw}
  .dialog, .modal-card{
    max-width:calc(100vw - 24px)!important;
    width:calc(100vw - 24px)!important;
    margin-left:auto!important;
    margin-right:auto!important;
  }

  /* Поля и селекты не раздвигают страницу */
  input,select,textarea{
    max-width:100%;
    box-sizing:border-box;
  }
}

/* v23.56: keep the progress ring out of the object title on narrow phones. */
@media(max-width:700px){
  #stages .stage-object-summary{position:relative!important;display:grid!important;grid-template-columns:minmax(0,1fr)!important;padding:12px!important;gap:8px!important;overflow:hidden!important}
  #stages .stage-object-summary>div:first-child{min-width:0!important;padding-right:78px!important}
  #stages .stage-object-summary>div:first-child b{display:block!important;max-width:100%!important;overflow-wrap:anywhere!important;word-break:normal!important}
  #stages .stage-progress-ring{left:auto!important;right:12px!important;top:12px!important;width:62px!important;height:62px!important;flex:none!important}
}
@media(max-width:430px){#stages .stage-object-summary{padding-top:12px!important}}
@media(max-width:700px){
  #stages .stage-object-kpis{gap:4px!important}
  #stages .stage-object-kpis span{padding:4px 6px!important;min-height:0!important;font-size:8px!important;line-height:1.05!important}
  #stages .stage-object-kpis b{font-size:11px!important;line-height:1!important}
}

@media (max-width:380px){
  .mobile-menu-grid{grid-template-columns:1fr}
  .tariff-table{font-size:10px}
  main{padding:10px!important}
}

/* ===== v16.74 Mobile reliability ===== */
@media(max-width:768px){
  .mobile-brand{
    display:flex;
    align-items:center;
    gap:8px;
    min-width:0;
    color:#172033;
  }
  
  
  .mobile-brand small{
    font-size:10px;
    color:#8b96a5;
    font-weight:700;
  }

  .mobile-action-sheet{max-height:88vh}
  .mobile-action-list{display:grid;grid-template-columns:1fr;gap:8px}
  .mobile-action-list button{
    width:100%;
    min-height:48px;
    border:1px solid #e0e6ed;
    background:#f8fafc;
    border-radius:13px;
    padding:11px 13px;
    text-align:left;
    font-size:13px;
    font-weight:700;
  }
  .mobile-action-section{
    margin-top:14px;
    padding-top:12px;
    border-top:1px solid #edf0f4;
  }
  .mobile-action-title{
    font-size:13px;
    font-weight:800;
    margin-bottom:8px;
  }
  .mobile-export-row{
    display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:8px;
  }
  .mobile-export-row button{
    min-width:0;
    width:100%;
    min-height:42px;
    border:1px solid #dfe5ec;
    border-radius:11px;
    background:#f7f9fc;
    font-size:12px;
    font-weight:800;
  }

  /* File/Service dropdowns remain desktop-only. Mobile uses dedicated sheets. */
  #fileMenuDropdown,#serviceMenuDropdown{display:none!important}
}

/* ===== v16.74 Mobile layout cleanup ===== */
@media(max-width:768px){
  .mobile-company-tariff{
    display:flex;
    align-items:center;
    justify-content:center;
    width:100%;
    min-height:42px;
    margin-top:9px;
    padding:9px 12px;
    box-sizing:border-box;
    border:1px solid #dce4ed;
    border-radius:12px;
    background:#f7f9fc;
    color:#263244;
    font-size:13px;
    font-weight:800;
    text-align:center;
    gap:6px;
  }
  .mobile-company-tariff:active{background:#eef3f8}
  .mobile-company-sep{color:#a0a9b6}
  .mobile-company-arrow{margin-left:auto;font-size:21px;line-height:1;color:#8a96a5}

  .section-title .mobile-project-actions{
    display:grid!important;
    grid-template-columns:1fr;
    gap:9px;
    width:100%;
  }
  .mobile-project-action-btn{
    width:100%!important;
    min-height:46px!important;
    margin:0!important;
    border-radius:13px!important;
    box-sizing:border-box;
  }

  
}

/* Hide mobile-only action stack on desktop; keep original desktop layout unaffected */
@media(min-width:769px){
  .mobile-project-actions{
    display:contents;
  }
  .mobile-project-actions .mobile-project-action-btn:not(:first-child){
    display:none!important;
  }
  .mobile-company-tariff{display:none!important}
}

/* ===== v16.74 inline mobile tabs / documents ===== */
@media(max-width:768px){
  body{padding-bottom:0!important}
  

  
  
  
  
  .mobile-doc-first{margin-top:0!important;padding-top:0!important;border-top:0!important}
}


/* ===== v16.74 Account page + persistent mobile nav ===== */
.account-tabs{
  display:flex;
  gap:8px;
  margin:14px 0 16px;
  padding:4px;
  background:#f1f4f8;
  border-radius:14px;
}
.account-tab{
  flex:1;
  min-height:42px;
  border:0;
  border-radius:10px;
  background:transparent;
  font-weight:800;
  color:#677383;
}
.account-tab.active{
  background:#fff;
  color:#1769e0;
  box-shadow:0 1px 4px rgba(20,32,46,.08);
}
.account-pane{display:none}
.account-pane.active{display:block}
.account-profile-card{
  padding:18px;
  margin-bottom:14px;
}
.account-profile-name{font-size:21px;font-weight:850;margin-bottom:4px}
.account-profile-meta{font-size:13px;color:#74808e;line-height:1.55}
.account-actions{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
  margin-top:14px;
}
.account-actions button{
  width:100%;
  min-height:46px;
  border-radius:12px;
}
.account-subscription-title{margin-bottom:14px}

.mobile-persistent-tabs{display:none}

@media(max-width:768px){
  /* Persistent navigation stays visible on every app view */
  .mobile-persistent-tabs{
    display:grid;
    grid-template-columns:repeat(5,minmax(0,1fr));
    gap:4px;
    position:sticky;
    top:96px;
    z-index:1180;
    width:100%;
    box-sizing:border-box;
    padding:7px 8px;
    background:rgba(255,255,255,.97);
    border-bottom:1px solid #e5e9ef;
    backdrop-filter:blur(14px);
  }
  .mobile-persistent-tabs button{
    min-width:0;
    min-height:48px;
    border:0;
    border-radius:10px;
    background:transparent;
    color:#697586;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:2px;
    padding:4px 1px;
    font-size:9px;
    font-weight:800;
  }
  .mobile-persistent-tabs button span{
    font-size:17px;
    line-height:1;
  }
  .mobile-persistent-tabs button.active{
    background:#eef5ff;
    color:#1769e0;
  }

  /* Old per-estimate tab row no longer used */
  

  #account{padding-top:0}
  .account-page-head h1{margin-bottom:4px}
  .account-tabs{
    position:sticky;
    top:160px;
    z-index:1100;
    background:#f1f4f8;
  }
}

@media(max-width:380px){
  .mobile-persistent-tabs button{font-size:8px}
  .mobile-persistent-tabs{padding-left:4px;padding-right:4px}
}

/* ===== v16.74 Account tabs positioning fix ===== */
@media(max-width:768px){
  #account .account-page-head{
    margin-bottom:10px;
  }

  #account .account-tabs{
    position:static!important;
    top:auto!important;
    z-index:auto!important;
    margin:0 0 16px!important;
    padding:4px!important;
    width:100%!important;
    box-sizing:border-box!important;
    transform:none!important;
  }

  #account .account-pane{
    margin-top:0!important;
    padding-top:0!important;
  }

  #account .account-profile-card{
    margin-top:0!important;
  }
}

/* ===== v16.74 Embedded account users ===== */
.account-users-card{margin-top:16px}
.account-users-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:14px}
.account-user-form{
  display:grid;
  grid-template-columns:1.1fr 1fr 1.3fr 1fr .9fr auto;
  gap:8px;
  align-items:center;
  margin-bottom:16px;
}
.account-user-form input,.account-user-form select{min-width:0}
.account-users-company{margin-bottom:8px}
.account-user-row{
  display:grid;
  grid-template-columns:1.4fr .8fr .7fr auto;
  gap:8px;
  align-items:center;
  padding:11px 0;
  border-top:1px solid #edf0f4;
}
.account-user-row-actions{display:flex;gap:6px;flex-wrap:wrap}
.account-user-status{font-size:12px;color:#6f7b89}

@media(max-width:768px){
  .account-user-form{
    grid-template-columns:1fr;
  }
  .account-user-form button{
    width:100%;
    min-height:46px;
  }
  .account-user-row{
    grid-template-columns:1fr;
    gap:9px;
    padding:14px 0;
  }
  .account-user-row select{width:100%}
  .account-user-row-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:7px;
  }
  .account-user-row-actions .btn-danger{
    grid-column:1/-1;
  }
}

/* ===== v16.74 Tariff prices ===== */
.subscription-price{
  font-size:24px;
  font-weight:850;
  letter-spacing:-.4px;
}
.subscription-period{
  margin-top:2px;
  font-size:12px;
  color:#7b8794;
  font-weight:600;
}

/* ===== v16.74 Billing period ===== */
.billing-toggle-wrap{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:7px;
  margin:4px 0 18px;
}
.billing-toggle{
  display:flex;
  gap:4px;
  padding:4px;
  border-radius:14px;
  background:#eef2f6;
}
.billing-toggle button{
  border:0;
  border-radius:10px;
  min-height:40px;
  padding:8px 16px;
  background:transparent;
  color:#687586;
  font-weight:800;
  cursor:pointer;
}
.billing-toggle button.active{
  background:#fff;
  color:#1769e0;
  box-shadow:0 1px 5px rgba(20,32,46,.10);
}
.billing-toggle button span{
  color:#14804a;
  font-size:11px;
}
.billing-saving-hint{text-align:center}
.subscription-price[data-price-plan="pro"]{font-size:28px}
@media(max-width:768px){
  .billing-toggle{width:100%;box-sizing:border-box}
  .billing-toggle button{flex:1;padding-left:6px;padding-right:6px}
}

/* ===== v16.74 Opaque mobile top tabs ===== */
@media(max-width:768px){
  .mobile-persistent-tabs{
    background:#ffffff!important;
    backdrop-filter:none!important;
    -webkit-backdrop-filter:none!important;
    opacity:1!important;
  }
}

/* ===== v16.74 Tariffs heading ===== */
.subscription-tariffs-heading{
  margin:18px 0 10px;
}
.subscription-tariffs-heading h2{
  margin:0;
  font-size:22px;
  font-weight:850;
  letter-spacing:-.3px;
}
@media(max-width:768px){
  .subscription-tariffs-heading{
    margin:16px 0 9px;
  }
  .subscription-tariffs-heading h2{
    font-size:20px;
  }
}


/* ===== v16.74 Settings tabs + requisites/logo ===== */





.logo-settings-row{
  display:grid;
  grid-template-columns:150px minmax(0,1fr);
  gap:18px;
  align-items:center;
  margin:10px 0 24px;
}
.company-logo-preview{
  width:150px;
  height:100px;
  border:1px dashed #cbd5df;
  border-radius:14px;
  background:#f8fafc;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  color:#94a3b8;
  font-weight:800;
}
.company-logo-preview img{
  max-width:100%;
  max-height:100%;
  object-fit:contain;
  display:block;
}
.logo-settings-actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}
.logo-settings-actions .small{flex-basis:100%;max-width:640px}
@media(max-width:768px){
  
  
  .logo-settings-row{grid-template-columns:1fr}
  .company-logo-preview{width:100%;height:120px}
}


/* ===== v16.74 REST API v1 ===== */














/* ===== v16.74 Logout controls ===== */
.account-explicit-logout{
  margin:12px 0 18px;
}
.account-logout-btn{
  min-width:180px;
}
.mobile-logout-button{
  color:#b42318!important;
  border-color:#fecaca!important;
  background:#fff7f7!important;
  font-weight:800!important;
}
@media(max-width:768px){
  .account-logout-btn{width:100%}
}

/* v16.74 CloudPayments */
.payment-consent-card{margin:14px 0 18px}
.payment-consent-label{display:flex;gap:10px;align-items:flex-start;cursor:pointer;line-height:1.4}
.payment-consent-label input{margin-top:3px;transform:scale(1.15)}
.payment-consent-title{margin:0 0 12px;font-size:20px}
.payment-policy-list{display:grid;gap:9px}
.payment-policy{border:1px solid var(--line);border-radius:11px;padding:0 12px;background:color-mix(in srgb,var(--card) 82%,var(--bg) 18%)}
.payment-policy summary{cursor:pointer;font-weight:700;padding:12px 4px;list-style:none}
.payment-policy summary::-webkit-details-marker{display:none}
.payment-policy summary::after{content:'＋';float:right;color:var(--muted)}
.payment-policy[open] summary::after{content:'−'}
.payment-policy-text{padding:0 4px 12px;line-height:1.5;color:var(--muted);font-size:14px}
.payment-consent-required{padding-top:3px;font-weight:700}
.payment-consent-modal-box{width:min(680px,calc(100vw - 24px));max-height:min(88dvh,820px);overflow:auto}
.payment-consent-modal-status{margin-top:12px;min-height:22px}
.payment-consent-modal .payment-policy-list{margin-top:12px}
.payment-consent-modal .payment-consent-label{padding:2px 0 5px}
.payment-history-list{display:grid;gap:8px}
.payment-history-row{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-top:1px solid #e8edf3}
.payment-history-row:first-child{border-top:0}
.payment-status-paid{color:#157347;font-weight:700}
.payment-status-failed{color:#b42318;font-weight:700}
.payment-status-created{color:#667085;font-weight:700}
@media(max-width:768px){.payment-history-row{display:block}.payment-history-row>div+div{margin-top:4px}}


/* ===== v16.74 unified in-app dialogs ===== */
.ais-dialog-overlay{
 position:fixed;inset:0;z-index:100000;display:none;align-items:center;justify-content:center;
 padding:20px;background:rgba(15,23,42,.42);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)
}
.ais-dialog-overlay.open{display:flex}
.ais-dialog-card{
 position:relative;width:min(460px,calc(100vw - 32px));max-height:min(80vh,680px);overflow:auto;
 background:var(--card,#fff);color:var(--text,#111827);border:1px solid var(--border,#e5e7eb);
 border-radius:24px;padding:26px;box-shadow:0 24px 80px rgba(15,23,42,.24);
 animation:aisDialogIn .16s ease-out
}
@keyframes aisDialogIn{from{opacity:0;transform:translateY(8px) scale(.985)}to{opacity:1;transform:none}}
.ais-dialog-close{
 position:absolute;right:16px;top:14px;width:36px;height:36px;border:0;border-radius:50%;
 background:var(--soft,#f3f4f6);color:inherit;font-size:24px;line-height:32px;cursor:pointer
}
.ais-dialog-icon{
 width:48px;height:48px;border-radius:15px;display:flex;align-items:center;justify-content:center;
 font-weight:800;font-size:14px;letter-spacing:-.02em;background:var(--soft,#f3f4f6);margin-bottom:16px
}
.ais-dialog-title{font-size:22px;line-height:1.15;margin:0 42px 10px 0}
.ais-dialog-message{font-size:15px;line-height:1.55;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--muted,#667085)}
.ais-dialog-input{
 box-sizing:border-box;width:100%;margin-top:16px;padding:12px 14px;border:1px solid var(--border,#d0d5dd);
 border-radius:12px;background:var(--card,#fff);color:var(--text,#111827);font:inherit;outline:none
}
.ais-dialog-input:focus{box-shadow:0 0 0 3px rgba(37,99,235,.12)}
.ais-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:22px;flex-wrap:wrap}
@media(max-width:600px){
 .ais-dialog-overlay{align-items:flex-end;padding:12px}
 .ais-dialog-card{width:100%;border-radius:24px 24px 18px 18px;padding:24px 20px 20px}
 .ais-dialog-actions{display:grid;grid-template-columns:1fr 1fr}
 .ais-dialog-actions button:only-child{grid-column:1/-1}
}


/* ===== v16.74 modal layer fix =====
   Все модальные окна приложения обязаны быть выше шапки, бокового меню,
   мобильной навигации и action sheets. */



body:has(.modal.open){overflow:hidden}

/* Фирменные alert/confirm/prompt всегда поверх обычной модалки. */
.ais-dialog-overlay{z-index:60000!important}

/* Мобильные меню ниже модальных окон. */
.mobile-more-overlay, .mobile-topbar, header{isolation:auto}



/* Fallback для браузеров без dvh. */



/* ===== v16.74 dialog above admin/company overlays =====
   Окна aisAlert/aisConfirm/aisPrompt всегда должны быть верхним слоем,
   включая окно создания/редактирования компании (auth overlay z-index 100000+). */
.ais-dialog-overlay{
  z-index:300000!important;
}


/* ===== v16.74 Estimates hub ===== */
.estimates-hub-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;
  margin:0 0 16px;
}
.estimates-hub-head h1{margin:0 0 5px}
.estimates-hub-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-bottom:14px;
}
.estimates-hub-actions .btn{
  min-height:46px;
  border-radius:12px;
}

.estimates-search-card{
  display:flex;
  align-items:center;
  gap:14px;
  padding:12px 14px;
  margin-bottom:14px;
  box-shadow:none;
}
.estimates-search-card input{
  flex:1;
  min-width:180px;
}
.estimates-hub-list{
  display:grid;
  gap:12px;
}
.estimate-hub-card{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:20px;
  align-items:center;
  padding:18px 20px;
  transition:border-color .15s ease,box-shadow .15s ease,transform .15s ease;
}
.estimate-hub-card:hover{
  border-color:#bdd3f4;
  box-shadow:0 10px 30px rgba(20,48,86,.10);
}
.estimate-hub-card.current{
  border-color:#88b6f5;
  box-shadow:inset 4px 0 0 #1769e0,var(--shadow);
}
.estimate-hub-title-row{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.estimate-hub-title-row h2{
  margin:0;
  font-size:19px;
}
.estimate-current-badge{
  display:inline-flex;
  align-items:center;
  min-height:24px;
  padding:3px 9px;
  border-radius:999px;
  background:#eaf2ff;
  color:#1769e0;
  font-size:11px;
  font-weight:850;
}
.estimate-hub-meta{
  display:flex;
  flex-wrap:wrap;
  gap:6px 16px;
  margin-top:7px;
  color:#6f7b89;
  font-size:12px;
}
.estimate-hub-meta span:not(:last-child)::after{
  content:"";
}
.estimate-hub-stats{
  display:flex;
  flex-wrap:wrap;
  gap:14px;
  margin-top:12px;
  font-size:13px;
  color:#5f6b7a;
}
.estimate-hub-stats b{color:#1d2430}
.estimate-hub-actions{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.estimate-hub-actions button{white-space:nowrap}
.estimates-empty{
  text-align:center;
  padding:44px 20px;
}
.estimates-empty-icon{
  width:56px;height:56px;border-radius:18px;
  background:#eef5ff;color:#1769e0;
  display:flex;align-items:center;justify-content:center;
  margin:0 auto 14px;font-size:28px;font-weight:800;
}
.estimates-empty h2{margin-bottom:7px}
.estimates-empty .btn{margin-top:18px}
.estimate-back-row{
  margin-bottom:12px;
}
.estimate-back-btn{
  min-height:38px;
  padding:8px 12px;
  color:#1769e0;
}
@media(max-width:768px){
  .estimates-hub-head{margin-top:2px}
  .estimates-hub-actions{
    display:grid;
    grid-template-columns:1fr;
  }
  .estimates-hub-actions .btn{
    width:100%;
    min-height:49px;
  }
  .estimates-search-card{
    display:block;
  }
  .estimates-search-card input{
    width:100%;
    box-sizing:border-box;
  }
  #estimatesHubLimit{margin-top:8px}
  .estimate-hub-card{
    grid-template-columns:1fr;
    gap:14px;
    padding:16px;
  }
  .estimate-hub-card.current{
    box-shadow:inset 3px 0 0 #1769e0,var(--shadow);
  }
  .estimate-hub-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
  }
  .estimate-hub-actions .btn{
    grid-column:1/-1;
  }
  .estimate-hub-actions button{
    width:100%;
    min-height:43px;
  }
  .estimate-back-btn{
    width:auto!important;
  }
}


/* ===== v16.74 Documents from estimates list ===== */
.estimate-documents-btn{
  color:#1769e0;
  background:#eef5ff;
}
.estimate-documents-btn:hover{
  background:#e2edff;
}


/* ===== v16.74 library editor buttons ===== */
.item-modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
}
.item-modal-actions button{min-width:120px}
@media(max-width:560px){
  .item-modal-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    position:sticky;
    bottom:0;
    background:#fff;
    padding-top:12px;
  }
  .item-modal-actions button{
    width:100%;
    min-height:46px;
  }
}


/* ===== v16.74 compact «Состав работ» ===== */
.subworks-library-view{
  height:calc(100vh - 108px);
  min-height:520px;
  display:none;
  flex-direction:column;
  overflow:hidden!important;
}
.subworks-library-view.active{display:flex!important}
.subworks-library-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  flex:0 0 auto;
  margin-bottom:10px;
}
.subworks-library-top h1{
  margin:0 0 2px;
  font-size:26px;
}
.subworks-library-top input{
  width:min(340px,40vw);
  min-height:40px;
}
#subworksLibraryGroups{
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
  padding:1px 2px 12px 1px;
}
.subwork-library-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(280px,1fr));
  gap:10px;
  align-items:start;
}
.subwork-library-group-compact{
  min-width:0;
  border:1px solid #dde4ec;
  border-radius:12px;
  background:#fff;
  overflow:hidden;
  box-shadow:0 2px 8px rgba(20,32,46,.04);
}
.subwork-library-head-compact{
  width:100%;
  min-height:38px;
  padding:7px 9px;
  display:grid;
  grid-template-columns:24px minmax(0,1fr) auto;
  gap:6px;
  align-items:center;
  text-align:left;
  border:0;
  border-radius:0;
  background:#f5f7fa;
  color:#26364a;
}
.subwork-library-head-compact:hover{background:#eef3f8}
.subwork-library-chevron{
  width:24px;height:24px;
  display:flex;align-items:center;justify-content:center;
  border-radius:7px;
  background:#fff;
  border:1px solid #d7dee7;
  color:#1769e0;
  font-weight:900;
  font-size:15px;
}
.subwork-library-category{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:13px;
  font-weight:850;
}
.subwork-library-count{
  min-width:24px;
  padding:2px 6px;
  border-radius:999px;
  background:#e7edf5;
  text-align:center;
  color:#657182;
  font-size:10px;
  font-weight:850;
}
.subwork-library-rows-compact{
  max-height:calc((100vh - 215px) / 2);
  overflow:auto;
}
.subwork-library-row-compact{
  width:100%;
  min-height:38px;
  padding:5px 8px;
  display:grid;
  grid-template-columns:minmax(0,1fr) 46px 82px 22px;
  gap:5px;
  align-items:center;
  text-align:left;
  border:0;
  border-radius:0;
  border-top:1px solid #eef1f5;
  background:#fff;
  color:#273243;
  font-weight:400;
}
.subwork-library-row-compact:hover{background:#f8fbff}
.subwork-library-name{
  min-width:0;
  display:block;
  line-height:1.15;
}
.subwork-library-name b{
  display:block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:11.5px;
  font-weight:750;
}
.subwork-library-name small{
  display:block;
  margin-top:1px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#8a95a3;
  font-size:9px;
}
.subwork-library-unit{
  color:#687586;
  font-size:10px;
  text-align:center;
}
.subwork-library-price{
  font-size:10px;
  font-weight:800;
  text-align:right;
  white-space:nowrap;
}
.subwork-library-edit{
  color:#1769e0;
  font-size:13px;
  text-align:center;
}
.subwork-library-group-compact.collapsed .subwork-library-head-compact{
  background:#f8fafc;
}
@media(max-width:1250px){
  .subwork-library-grid{grid-template-columns:repeat(2,minmax(270px,1fr))}
}
@media(max-width:768px){
  .subworks-library-view{
    height:calc(100dvh - 178px);
    min-height:0;
  }
  .subworks-library-top{
    display:grid;
    grid-template-columns:1fr;
    gap:8px;
    margin-bottom:8px;
  }
  .subworks-library-top h1{font-size:24px}
  .subworks-library-top input{
    width:100%;
    min-height:42px;
  }
  .subwork-library-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:7px;
  }
  .subwork-library-head-compact{
    grid-template-columns:22px minmax(0,1fr) auto;
    padding:6px;
  }
  .subwork-library-category{font-size:11px}
  .subwork-library-rows-compact{
    max-height:calc((100dvh - 270px) / 2);
  }
  .subwork-library-row-compact{
    grid-template-columns:minmax(0,1fr) 36px;
    gap:4px;
    padding:5px 6px;
  }
  .subwork-library-unit,
  .subwork-library-price{display:none}
  .subwork-library-name b{font-size:10.5px}
  .subwork-library-name small{font-size:8px}
}
@media(max-width:430px){
  .subwork-library-grid{grid-template-columns:1fr 1fr}
  .subwork-library-count{display:none}
}

/* ===== v16.116 — foreman-first mobile dashboard ===== */
.foreman-dashboard{display:none}
@media(max-width:768px){
  body{padding-bottom:76px!important}
  .mobile-company-tariff,.mobile-save-status{display:none!important}
  .mobile-topbar{padding:10px 14px!important}.mobile-brand{font-size:20px!important}.mobile-brand small{font-size:10px!important}
  #mobilePersistentTabs.foreman-five-tabs{
    position:fixed!important;left:0!important;right:0!important;bottom:0!important;top:auto!important;z-index:120!important;
    display:grid!important;grid-template-columns:repeat(5,minmax(0,1fr))!important;gap:0!important;
    margin:0!important;padding:6px max(5px,env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom))!important;
    min-height:70px!important;background:rgba(250,250,252,.94)!important;border-top:1px solid rgba(60,60,67,.15)!important;border-bottom:0!important;
    box-shadow:0 -5px 24px rgba(0,0,0,.06)!important;backdrop-filter:blur(24px)!important;-webkit-backdrop-filter:blur(24px)!important
  }
  html[data-theme="dark"] #mobilePersistentTabs.foreman-five-tabs{background:rgba(20,20,22,.96)!important;border-color:rgba(255,255,255,.12)!important}
  #mobilePersistentTabs.foreman-five-tabs>button,#mobilePersistentTabs.foreman-five-tabs>button:not(.context-hidden){
    display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:center!important;gap:2px!important;
    width:100%!important;min-width:0!important;min-height:56px!important;padding:3px 1px!important;border:0!important;border-radius:10px!important;
    background:transparent!important;color:#77777d!important;box-shadow:none!important;font-size:9.5px!important;font-weight:570!important
  }
  #mobilePersistentTabs.foreman-five-tabs>button.active{background:transparent!important;color:#0071e3!important;box-shadow:none!important}
  
  #mobilePersistentTabs.foreman-five-tabs .ais-tab-icon,#mobilePersistentTabs.foreman-five-tabs .foreman-more-icon svg{width:23px!important;height:23px!important;fill:none;stroke:currentColor;stroke-width:1.8}
  #mobilePersistentTabs.foreman-five-tabs .foreman-more-icon svg circle{fill:currentColor;stroke:none}
  main{padding:14px 12px 32px!important}
  .foreman-dashboard{display:block}
  #estimates>.estimates-hub-head,#estimates>.estimates-hub-actions{display:none!important}
  
  
  
  
  
  
  .foreman-progress{--progress:0;width:104px;aspect-ratio:1;border-radius:50%;display:grid;place-items:center;align-content:center;position:relative;background:conic-gradient(#0071e3 calc(var(--progress)*1%),#e5e5ea 0)}
  .foreman-progress::before{content:"";position:absolute;inset:8px;border-radius:50%;background:#fff}.foreman-progress span,.foreman-progress small{position:relative;z-index:1}.foreman-progress span{font-size:24px;font-weight:760}.foreman-progress small{font-size:9px;text-transform:uppercase;color:#6e6e73;margin-top:1px}
  
  
  
  
  
  
  #estimates>.estimates-search-card{margin-bottom:10px!important;padding:5px 8px!important;border-radius:13px!important}#estimatesHubLimit{display:none!important}
  #estimatesHubList .estimate-hub-card{padding:13px!important;border-radius:14px!important;margin-bottom:8px!important;box-shadow:0 3px 13px rgba(0,0,0,.045)!important}
  #estimatesHubList .estimate-hub-meta span:nth-child(3){display:none}#estimatesHubList .estimate-hub-actions{grid-template-columns:1fr 1fr!important}
  #estimatesHubList .estimate-hub-actions .btn-light:not(.estimate-documents-btn),#estimatesHubList .estimate-hub-actions .btn-danger{display:none!important}
  #works .section-title,#materials .section-title{align-items:flex-end!important;gap:10px!important;margin-bottom:12px!important}
  #works .section-title .small{display:none!important}#works .section-title h1,#materials .section-title h1{font-size:28px!important;margin:0!important}
  #works .section-title .btn,#materials .section-title .btn{width:auto!important;min-height:42px!important;padding:8px 13px!important;font-size:12px!important;white-space:nowrap}
  #works>.toolbar,#materials>.toolbar{position:relative;margin-bottom:12px!important}#works>.toolbar input,#materials>.toolbar input{width:100%;min-height:48px!important;padding-left:15px!important;border-radius:14px!important}
  #works .works-tree-card,#materials>.card{padding:0!important;background:transparent!important;border:0!important;box-shadow:none!important;overflow:visible!important}
  #works table,#materials table{display:block;background:transparent!important}#works thead,#materials thead{display:none!important}#works tbody,#materials tbody{display:block}
  #works tbody tr,#materials tbody tr{margin-bottom:8px;border:1px solid rgba(60,60,67,.1);border-radius:14px;background:#fff;box-shadow:0 3px 12px rgba(0,0,0,.045);overflow:hidden}
  #works .work-category-row,#materials .material-category-row{display:block!important}#works .work-category-row td,#materials .material-category-row td{display:block!important;padding:13px!important;background:#f7faff!important;border:0!important}
  #works .work-tree-parent{display:grid!important;grid-template-columns:36px minmax(0,1fr) auto!important;align-items:center;padding:6px!important}
  #works .work-tree-parent td{display:block!important;border:0!important;padding:7px!important}#works .work-tree-parent td:nth-child(3){display:none!important}#works .work-tree-parent .work-tree-actions{grid-column:1/-1;display:flex!important;gap:5px;padding-top:0!important}#works .work-tree-parent .work-tree-actions button{font-size:10px!important;padding:6px 8px!important;min-height:30px!important}
  #works .work-tree-section-head,#works .work-tree-child,#works .work-tree-material,#works .work-tree-section-add{display:table-row!important}
  #materials tbody tr:not(.material-category-row){display:grid!important;grid-template-columns:minmax(0,1fr) auto;align-items:center;padding:8px 10px!important}#materials tbody tr:not(.material-category-row) td{display:none!important;border:0!important;padding:5px!important}#materials tbody tr:not(.material-category-row) td:nth-child(2),#materials tbody tr:not(.material-category-row) td:nth-child(5),#materials tbody tr:not(.material-category-row) td:last-child{display:block!important}#materials tbody tr:not(.material-category-row) td:nth-child(2){font-weight:650}#materials tbody tr:not(.material-category-row) td:last-child{grid-column:1/-1}
  html[data-theme="dark"] #works tbody tr, html[data-theme="dark"] #materials tbody tr{background:#1c1c1e!important;color:#f5f5f7!important;border-color:rgba(255,255,255,.12)!important;box-shadow:none!important}
  html[data-theme="dark"] .foreman-progress{background:conic-gradient(#0a84ff calc(var(--progress)*1%),#38383a 0)}html[data-theme="dark"] .foreman-progress::before{background:#1c1c1e}
}
@media(max-width:370px){
  #mobilePersistentTabs.foreman-five-tabs>button{font-size:8.4px!important}.foreman-progress{width:90px}
}


/* ===== v16.74 demo mode ===== */
#aiDemoModeBanner button{cursor:pointer}
@media(max-width:768px){
  #aiDemoModeBanner{
    font-size:12px!important;
    gap:8px!important;
    padding:8px 10px!important;
  }
  #aiDemoModeBanner button{
    width:100%;
    min-height:40px;
  }
}


/* ===== v16.74 estimates hub: AI is the single primary CTA ===== */
.estimates-ai-only-action{
  font-weight:800;
}
.estimates-search-card{
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:10px;
}




/* ===== v16.74 AI-first dictation ===== */
#aiDictationStatus{line-height:1.35}
#aiDictationBtn:disabled{opacity:.6;cursor:wait}


/* ===== v16.74 simplified AI estimate voice UI ===== */






/* ===== v16.74 CTA hierarchy: Create is primary, Dictate is compact ===== */






/* ===== v16.74 coupons ===== */
.payment-coupon-card{margin-bottom:14px}
.payment-coupon-title{font-weight:800;margin-bottom:9px}
.payment-coupon-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.payment-coupon-row input{min-width:220px;flex:1;text-transform:uppercase}
.coupon-create-row{display:flex;gap:12px;align-items:end;flex-wrap:wrap}
.coupon-create-row label{max-width:180px}
.coupon-created-code{font-size:17px;letter-spacing:.06em}
.coupon-admin-row{
  display:grid;
  grid-template-columns:minmax(170px,1fr) 150px 120px auto;
  gap:12px;
  align-items:end;
  padding:12px 0;
  border-top:1px solid #edf0f4;
}
.coupon-admin-row:first-child{border-top:0}
.coupon-code b{font-size:16px;letter-spacing:.04em}
.coupon-active-label{display:flex!important;align-items:center;gap:7px;min-height:40px}
.coupon-active-label input{width:auto}
@media(max-width:700px){
  .payment-coupon-row{display:grid;grid-template-columns:1fr auto}
  .payment-coupon-row input{min-width:0}
  .coupon-admin-row{grid-template-columns:1fr 110px}
  .coupon-admin-row .coupon-code{grid-column:1/-1}
}


/* ===== v16.74 mobile primary tabs: add Состав работ ===== */
@media(max-width:768px){
  .mobile-persistent-tabs{
    gap:2px!important;
    padding:6px 5px!important;
  }
  .mobile-persistent-tabs button{
    min-height:45px!important;
    border-radius:9px!important;
    padding:3px 0!important;
    font-size:8.5px!important;
    letter-spacing:-.15px;
  }
  .mobile-persistent-tabs button span{
    font-size:15px!important;
  }
}
@media(max-width:360px){
  .mobile-persistent-tabs{padding-left:2px!important;padding-right:2px!important;gap:1px!important}
  .mobile-persistent-tabs button{font-size:7.8px!important}
  .mobile-persistent-tabs button span{font-size:14px!important}
}


/* ===== v16.74 works tree ===== */
.works-tree-card{padding:0!important}
.works-tree-table{min-width:860px}
.works-tree-table th:first-child{width:42px}
.works-tree-table th:nth-child(2){min-width:300px}
.works-tree-table th:nth-child(3){width:95px}
.works-tree-table th:nth-child(4){width:235px}

.work-tree-toggle-cell{text-align:center}
.work-tree-toggle{
  width:30px;height:30px;border:0;border-radius:8px;
  background:rgba(255,255,255,.72);cursor:pointer;
  font-size:17px;line-height:1;
}
.work-tree-parent-name{font-size:15px}
.work-tree-summary{margin-top:3px;color:#7c715f}
.work-tree-actions{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.work-tree-actions button{padding:7px 9px!important;font-size:12px!important}

.work-tree-child td{
  background:#fff;
  vertical-align:middle;
  border-top:1px solid #eef1f4;
}
.work-tree-child td:nth-child(2){
  border-left:3px solid #d6e5fb;
}
.work-tree-branch{
  text-align:right;
  color:#8aa5c8;
  font-weight:800;
  font-size:18px;
  padding-right:4px!important;
}
.work-tree-child input{
  width:100%;
  box-sizing:border-box;
  min-height:36px;
  padding:7px 9px;
}
.work-tree-child-name{font-weight:650}
.work-tree-child-unit{min-width:72px}
.work-tree-child-calc{min-width:220px}
.work-tree-calc-line{
  display:grid;
  grid-template-columns:76px auto 105px;
  gap:6px;
  align-items:center;
}
.work-tree-child-calc .small{
  text-align:right;
  margin-top:4px;
  font-weight:700;
}
.work-tree-child-actions{
  display:flex;
  gap:8px;
  align-items:center;
  justify-content:space-between;
}

.work-tree-add-row td{background:#f8fbff}



@media(max-width:760px){
  .works-tree-table{min-width:0;width:100%;max-width:100%}
  .work-tree-actions button{padding:8px!important}
  .work-tree-calc-line{grid-template-columns:minmax(64px,1fr) auto minmax(82px,1fr)}
}


/* ===== v16.74 materials inside works tree ===== */
.work-tree-material td{
  background:#f8fcf8;
  vertical-align:middle;
  border-top:1px solid #e4eee5;
}
.work-tree-material td:nth-child(2){border-left:3px solid #b9d9bd}
.work-tree-material-name{font-size:14px}
.work-tree-material-calc{min-width:220px}
.work-tree-rate-line{
  display:grid;
  grid-template-columns:auto 88px 1fr;
  gap:7px;
  align-items:center;
}
.work-tree-rate-line input{width:100%;min-height:36px;box-sizing:border-box}

.work-tree-add-material-row td{background:#f3fbf4}
.work-tree-material-select{width:100%;min-height:38px}



@media(max-width:760px){
  .work-tree-rate-line{grid-template-columns:auto 78px 1fr}
}


/* ===== v16.74 grouped work tree: subworks + materials ===== */
.work-tree-section-head td{
  background:#fbf3dc!important;
  border-top:1px solid #eadfbe!important;
  padding-top:5px!important;
  padding-bottom:5px!important;
}
.work-tree-section-head td:nth-child(2){border-left:3px solid #dfc983}
.work-tree-section-toggle{
  width:100%;
  display:flex;
  align-items:center;
  gap:9px;
  border:0;
  background:transparent;
  padding:7px 4px;
  text-align:left;
  cursor:pointer;
  color:#403927;
}
.work-tree-section-plus{
  width:25px;height:25px;
  display:inline-flex;align-items:center;justify-content:center;
  flex:0 0 25px;
  border:1px solid #d9c27a;
  border-radius:7px;
  background:#fffaf0;
  font-size:17px;font-weight:800;line-height:1;
}
.work-tree-section-title{font-weight:800;font-size:14px}
.work-tree-section-count{
  min-width:23px;
  padding:2px 7px;
  border-radius:999px;
  background:#efe1b7;
  color:#6d5b25;
  font-size:11px;
  font-weight:800;
  text-align:center;
}
.work-tree-section-subworks td,.work-tree-section-materials td{background:#fbf3dc!important}
.work-tree-subwork-item td{background:#fffdf7}
.work-tree-material td{background:#fffdf7}
.work-tree-subwork-item td:nth-child(2),
.work-tree-material td:nth-child(2){border-left:3px solid #ead9a7}
.work-tree-section-add td{
  background:#fffaf0!important;
  border-top:0!important;
  padding-top:3px!important;
  padding-bottom:8px!important;
}
.work-tree-section-add td:nth-child(2){border-left:3px solid #ead9a7}
.work-tree-section-add button{
  border:0;background:transparent;color:#80651e;
  font-weight:750;cursor:pointer;padding:5px 8px;text-align:left;
}
.work-tree-section-add button:hover{text-decoration:underline}


/* ===== v16.74 material creation + visual picker ===== */
.work-tree-material-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.work-tree-material-actions button{
  border:0;
  border-radius:9px;
  padding:8px 11px;
  font-weight:800;
  cursor:pointer;
}
.work-tree-new-material-btn{
  background:#fff4cf!important;
  color:#6f5618!important;
  border:1px solid #dfca88!important;
}
.work-tree-pick-material-btn{
  background:#fff!important;
  color:#2f5f9b!important;
  border:1px solid #cbd8e8!important;
}
.material-picker-modal-box{max-width:980px!important}
.material-picker-toolbar{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:14px;
}
.material-picker-toolbar input{
  flex:1;
  min-width:220px;
}
.material-picker-group{margin-bottom:18px}
.material-picker-group-title{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:8px;
  font-weight:850;
  color:#3e4650;
}
.material-picker-group-title span{
  min-width:24px;
  text-align:center;
  padding:2px 7px;
  border-radius:999px;
  background:#f0e3bc;
  color:#725b21;
  font-size:11px;
}
.material-picker-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
}
.material-picker-card{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:6px;
  min-height:104px;
  padding:12px;
  text-align:left;
  border:1px solid #dfe5eb;
  border-radius:12px;
  background:#fff;
  cursor:pointer;
  transition:.12s ease;
}
.material-picker-card:hover{
  transform:translateY(-1px);
  border-color:#b9cbe0;
  box-shadow:0 5px 16px rgba(0,0,0,.06);
}
.material-picker-name{
  font-weight:850;
  color:#222b34;
}
.material-picker-meta{
  font-size:12px;
  color:#6d7884;
}
.material-picker-select{
  margin-top:auto;
  font-size:12px;
  font-weight:850;
  color:#2469b4;
}
@media(max-width:760px){
  .material-picker-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .material-picker-toolbar{align-items:stretch;flex-direction:column}
}
@media(max-width:460px){
  .material-picker-grid{grid-template-columns:1fr}
}


/* ===== v16.74 material purchase/client prices ===== */
.material-picker-prices{
  display:flex;
  flex-wrap:wrap;
  gap:6px 10px;
  font-size:12px;
  color:#596675;
}
.material-picker-prices span:last-child{font-weight:800;color:#2c5f9f}
.work-tree-material-prices{
  margin-top:3px;
  color:#796634;
}


/* ===== v16.74 purchase price access ===== */
.catalog-admin-only{display:none!important}
body.catalog-admin .catalog-admin-only{display:table-cell!important}
body.catalog-admin label.catalog-admin-only{display:block!important}
body.catalog-admin span.catalog-admin-only{display:inline!important}


/* ===== v16.74 work cost/client price ===== */
.work-tree-work-prices{min-width:165px}



/* ===== v16.74 manually editable work cost ===== */
.work-cost-edit{
  margin-top:5px;
  display:flex!important;
  align-items:center;
  justify-content:flex-end;
  gap:7px;
}
.work-cost-edit input{
  width:112px;
  min-height:30px;
  padding:5px 7px;
  text-align:right;
  font-weight:800;
}


/* ===== v16.74 Pro lock for internal prices ===== */
.pro-field-badge{
  display:none;
  margin-left:5px;
  padding:1px 5px;
  border-radius:999px;
  font-size:10px;
  line-height:1.5;
  font-weight:900;
  letter-spacing:.02em;
  background:#eef3ff;
  color:#315da8;
  border:1px solid #cad8f4;
  vertical-align:1px;
}
.pro-field-badge.visible{display:inline-flex}
body.internal-prices-locked .pro-field-badge-static{display:inline-flex}
.pro-locked-field[readonly]{
  background:#f5f6f8!important;
  color:#697380!important;
  cursor:not-allowed;
}
.work-cost-edit input[readonly]{
  background:#f5f6f8!important;
  color:#697380!important;
  cursor:not-allowed;
}


/* ===== v16.74 universal tariff badges ===== */
.tariff-ui-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  margin-left:6px;
  padding:1px 6px;
  border-radius:999px;
  font-size:10px;
  line-height:1.5;
  font-weight:900;
  letter-spacing:.015em;
  white-space:nowrap;
  vertical-align:1px;
  background:#eef3ff;
  color:#315da8;
  border:1px solid #cad8f4;
}
.tariff-ui-badge[data-plan="pro_plus"]{
  background:#f3edff;
  color:#6940a5;
  border-color:#d9c9f2;
}
.tariff-feature-locked{
  position:relative;
}
button.tariff-feature-locked,
input.tariff-feature-locked,
select.tariff-feature-locked,
textarea.tariff-feature-locked{
  cursor:not-allowed!important;
}
.mobile-action-section.tariff-feature-locked>.tariff-ui-badge,
.export-menu-group.tariff-feature-locked>.tariff-ui-badge{
  margin-left:8px;
}

/* ===== v16.74 AI estimate wizard ===== */
.ai-wizard-box{overflow:auto}
.ai-wizard-progress{
  display:flex;align-items:center;gap:8px;margin:6px 0 24px;padding:14px 16px;
  border:1px solid #e5e9ef;border-radius:16px;background:#fafbfc;
}
.ai-wizard-progress-item{display:flex;align-items:center;gap:7px;color:#7a8491;white-space:nowrap;font-size:12px}
.ai-wizard-progress-item span{
  width:26px;height:26px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;
  background:#e9edf2;color:#66717e;font-weight:900;
}
.ai-wizard-progress-item.active{color:#1769e0}
.ai-wizard-progress-item.active span{background:#1769e0;color:#fff}
.ai-wizard-progress-item.done{color:#2d7b51}
.ai-wizard-progress-item.done span{background:#e8f6ee;color:#2d7b51}
.ai-wizard-progress-line{height:1px;flex:1;min-width:18px;background:#dfe4ea}
.ai-wizard-step{padding:2px 2px 4px}
.ai-wizard-step-kicker{font-size:12px;font-weight:900;color:#1769e0;text-transform:uppercase;letter-spacing:.04em;margin-bottom:5px}
.ai-wizard-step h3{font-size:25px;margin:0 0 7px}
.ai-wizard-help{margin-bottom:20px;line-height:1.5}
.ai-wizard-main-label{display:block;font-weight:800;margin-top:14px}
.ai-wizard-main-label input,.ai-wizard-main-label textarea{
  width:100%;box-sizing:border-box;margin-top:7px;border:1px solid #ccd5df;border-radius:12px;padding:13px 14px;font:inherit;background:#fff;
}
.ai-wizard-main-label input{font-size:17px}

.ai-wizard-actions{display:flex;justify-content:space-between;gap:10px;align-items:center;margin-top:24px;flex-wrap:wrap}
.ai-wizard-actions-end{justify-content:flex-end}
.ai-wizard-next{min-width:150px}
.ai-wizard-review-card{border:1px solid #e0e5eb;background:#fafbfc;border-radius:16px;padding:18px;margin-top:18px}
.ai-wizard-review-text{white-space:pre-wrap;line-height:1.55;margin-top:4px;max-height:180px;overflow:auto}
.ai-wizard-create-wrap{text-align:center;padding:27px 12px 10px}
.ai-wizard-create-btn{font-size:19px!important;padding:16px 28px!important;min-width:min(440px,100%);box-shadow:0 10px 28px rgba(23,105,224,.2)}
.ai-wizard-create-wrap .small{margin-top:10px}
.ai-wizard-edit-source{border:1px solid #e0e5eb;border-radius:14px;padding:12px 14px;background:#fafbfc;margin-top:15px}
.ai-wizard-edit-source summary{cursor:pointer;font-weight:800;color:#394657}
.ai-wizard-edit-source textarea{box-sizing:border-box;border:1px solid #ccd5df;border-radius:10px;padding:11px;font:inherit;background:#fff}
.ai-wizard-result-status{margin-top:16px;font-weight:700}
@media(max-width:680px){
  .ai-wizard-progress{padding:10px 8px;gap:4px;margin-bottom:18px}
  .ai-wizard-progress-item b{display:none}
  .ai-wizard-progress-item span{width:25px;height:25px}
  .ai-wizard-progress-line{min-width:8px}
  .ai-wizard-step h3{font-size:21px}
  .ai-wizard-actions{align-items:stretch}
  .ai-wizard-actions button{flex:1}
  .ai-wizard-create-btn{width:100%;min-width:0;font-size:17px!important}
  
}

/* ===== v16.74 dedicated dictation step ===== */
.ai-wizard-voice-stage{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:34px 12px 18px;min-height:240px}
.ai-wizard-dictation-btn{width:min(520px,100%);min-height:78px;font-size:21px!important;font-weight:900!important;border-radius:18px!important;box-shadow:0 12px 32px rgba(23,105,224,.22)}
.ai-wizard-dictation-status{margin-top:15px;max-width:620px;line-height:1.5}
.ai-wizard-skip-dictation{margin-top:24px;border:0;background:transparent;color:#7a8491;font-size:13px;font-weight:700;padding:8px 12px;cursor:pointer}
.ai-wizard-skip-dictation:hover{color:#394657;text-decoration:underline}
@media(max-width:560px){.ai-wizard-voice-stage{padding:22px 4px 10px;min-height:220px}.ai-wizard-dictation-btn{min-height:72px;font-size:19px!important}.ai-wizard-progress{overflow-x:auto}}

/* ===== v16.77 larger primary mobile navigation ===== */
@media(max-width:768px){
  .mobile-persistent-tabs{
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:5px;
    padding:7px 6px;
  }
  .mobile-persistent-tabs button{
    min-height:58px;
    border-radius:12px;
    padding:6px 2px;
    font-size:11px;
    line-height:1.08;
    font-weight:850;
  }
  .mobile-persistent-tabs button span{
    font-size:22px;
    line-height:1;
  }
}
@media(max-width:360px){
  .mobile-persistent-tabs{
    gap:3px;
    padding-left:4px;
    padding-right:4px;
  }
  .mobile-persistent-tabs button{
    min-height:54px;
    font-size:10px;
    padding-left:1px;
    padding-right:1px;
  }
  .mobile-persistent-tabs button span{font-size:20px}
}


/* ===== v16.77 mobile primary navigation visibility fix =====
   Always keep all four main tabs visible as one horizontal strip on phones. */
@media (max-width:768px){
  #mobilePersistentTabs.mobile-persistent-tabs{
    display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    width:100%!important;
    max-width:100%!important;
    overflow:visible!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs > button{
    display:flex!important;
    visibility:visible!important;
    opacity:1!important;
    min-width:0!important;
    width:auto!important;
  }
}
/* A phone in landscape can have a CSS viewport wider than 768px. */
@media (orientation:landscape) and (max-height:600px) and (max-width:1100px){
  #mobilePersistentTabs.mobile-persistent-tabs{
    display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    gap:5px!important;
    width:100%!important;
    max-width:100%!important;
    box-sizing:border-box!important;
    padding:6px 8px!important;
    background:#fff!important;
    border-bottom:1px solid #e5e9ef!important;
    position:sticky!important;
    top:0!important;
    z-index:1180!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs > button{
    display:flex!important;
    visibility:visible!important;
    opacity:1!important;
    min-width:0!important;
    width:auto!important;
    min-height:48px!important;
    padding:4px 2px!important;
    font-size:10px!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs > button span{font-size:19px!important}
}

/* ===== v16.81 — отдельное создание компании на мобильном ===== */
.mobile-company-open-create{
  width:100%;min-height:58px;border:0;border-radius:14px;background:#1769e0;color:#fff;
  font-size:17px;font-weight:850;padding:14px 18px;box-shadow:0 8px 22px rgba(23,105,224,.18);
}
.mobile-company-create-form{display:grid;gap:14px}
.mobile-company-create-form label{display:grid;gap:7px;font-size:14px;font-weight:750;color:#344054}
.mobile-company-create-form input{
  width:100%;box-sizing:border-box;min-height:52px;padding:13px 14px;border:1px solid #cfd8e3;
  border-radius:12px;background:#fff;font-size:16px;color:#172033;
}
.mobile-company-create-form input:focus{outline:2px solid rgba(23,105,224,.18);border-color:#1769e0}
.mobile-company-create-submit{
  width:100%;min-height:56px;margin-top:4px;border:0;border-radius:13px;background:#1769e0;color:#fff;
  font-size:17px;font-weight:850;padding:14px 18px;
}
@media(max-width:768px), (pointer:coarse){
  .company-admin-row{grid-template-columns:1fr!important;gap:12px!important;align-items:stretch!important}
  .company-admin-row select,.company-admin-row input[type=date]{min-height:46px;font-size:16px}
  .company-admin-row button{min-height:44px;padding:9px 13px}
}

/* v16.81 — визуальный редактор шаблонов документов */
.document-template-editor-modal{padding:0!important;align-items:stretch!important;justify-content:stretch!important;background:rgba(22,29,40,.62)!important}
.document-template-editor-shell{width:min(1180px,calc(100vw - 32px));height:min(940px,calc(100vh - 32px));margin:auto;background:#f4f5f7;border-radius:20px;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 28px 90px rgba(0,0,0,.28)}
.document-template-editor-head{display:flex;justify-content:space-between;align-items:center;gap:20px;padding:18px 22px 14px;background:#fff;border-bottom:1px solid #e3e6ea}
.document-template-editor-head h2{margin:0 0 3px;font-size:22px}.document-template-editor-close{width:42px;height:42px;border:0;border-radius:50%;background:#eef0f3;font-size:28px;line-height:1;cursor:pointer}
.document-template-editor-tabs{display:flex;gap:7px;padding:10px 18px;background:#fff;border-bottom:1px solid #e3e6ea;overflow-x:auto;scrollbar-width:none}.document-template-editor-tabs::-webkit-scrollbar{display:none}
.document-template-editor-tabs button{border:1px solid #d9dee6;background:#fff;border-radius:10px;padding:9px 13px;white-space:nowrap;font-weight:700;cursor:pointer}.document-template-editor-tabs button.active{background:#172033;color:#fff;border-color:#172033}
.document-template-editor-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:10px 18px;background:#fafbfc;border-bottom:1px solid #dde1e6}.template-mode-switch{display:flex;border:1px solid #d9dee6;border-radius:10px;overflow:hidden;background:#fff}.template-mode-switch button{border:0;background:#fff;padding:9px 12px;font-weight:700}.template-mode-switch button.active{background:#eaf1ff;color:#1f5bb5}.template-insert-field{display:flex;gap:6px}.template-insert-field select,.template-insert-field button{min-height:38px;border:1px solid #d6dbe3;border-radius:9px;background:#fff;padding:7px 10px}.template-insert-field button{font-weight:700}.template-editor-hint{color:#6a7280;font-size:12px;margin-left:auto}
.document-template-editor-workspace{flex:1;overflow:auto;padding:24px;background:#e7e9ed}.document-template-paper{width:794px;min-height:1123px;margin:0 auto;background:#fff;box-shadow:0 4px 20px rgba(0,0,0,.12);padding:74px 72px 70px;box-sizing:border-box;color:#181818;font-family:Arial,sans-serif;font-size:14px;line-height:1.52}
.template-editable{outline:none;border-radius:4px;transition:.15s}.template-editable[contenteditable="true"]:hover{background:#fff9dc;box-shadow:0 0 0 3px #fff9dc}.template-editable[contenteditable="true"]:focus{background:#fff6c8;box-shadow:0 0 0 2px #e8b624}
.template-paper-title{text-align:center;font-size:22px;font-weight:800;letter-spacing:.02em;margin:0 0 18px}.template-paper-subtitle{text-align:center;margin:-10px 0 18px;color:#535b68}.template-paper-city{min-width:180px}.template-paper-meta-row{display:flex;justify-content:space-between;margin:10px 0 22px}.template-paper-section{font-weight:800;margin:20px 0 8px;text-transform:uppercase}.template-paper-paragraph{margin:7px 0;text-align:justify}.template-paper-rule{height:2px;background:#222;margin:8px 0 22px}.template-paper-appendix{text-align:right;font-weight:700;margin-top:12px}.template-signatures{display:grid;grid-template-columns:1fr 1fr;gap:48px;margin-top:20px}.template-sign-title{font-weight:800}.template-sign-line{margin-top:30px;border-top:1px solid #333;padding-top:5px;color:#555}.template-page-break{margin:48px -72px 38px;border-top:2px dashed #ccd1d8;text-align:center;color:#9aa1aa;font-size:11px;padding-top:6px}.template-variable-chip{display:inline-flex;align-items:center;padding:1px 6px;margin:0 2px;border-radius:999px;background:#eaf1ff;color:#245da7;border:1px solid #bfd2f0;font-size:.88em;font-weight:700;white-space:nowrap}.template-preview-value{background:#eef6ee;border-radius:4px;padding:0 2px}.template-commercial-meta{display:grid;grid-template-columns:190px 1fr;border-top:1px solid #d8dce2;border-left:1px solid #d8dce2;margin-bottom:22px}.template-commercial-meta>div{padding:7px 9px;border-right:1px solid #d8dce2;border-bottom:1px solid #d8dce2}.template-meta-label{font-weight:700;background:#f7f8fa}.template-inline-edit{display:inline-block;min-width:80px}.template-paper-table{width:100%;border-collapse:collapse;margin:8px 0 9px;font-size:12px}.template-paper-table th,.template-paper-table td{border:1px solid #cfd4da;padding:6px 7px}.template-paper-table th{background:#f2f4f6;text-align:left}.template-auto-block-label{font-size:10px;color:#9097a1;text-align:right;margin-bottom:4px}.template-auto-total{text-align:right;font-weight:800;margin:6px 0 18px}.template-commercial-total{display:flex;justify-content:space-between;border-top:2px solid #222;padding-top:11px;margin-top:18px;font-size:16px}.template-paper-footer-preview{text-align:center;color:#858c96;font-size:10px;margin-top:55px}.template-readonly-note{margin-top:20px;background:#f5f7fa;border-radius:10px;padding:12px;color:#68707d;font-size:12px}.document-template-editor-footer{display:flex;justify-content:flex-end;gap:10px;padding:12px 18px;background:#fff;border-top:1px solid #dde1e6}.document-template-editor-footer button{min-height:42px;padding:9px 18px}
@media(max-width:820px){.document-template-editor-shell{width:100vw;height:100vh;max-height:none;border-radius:0}.document-template-editor-head{padding:13px 14px 10px}.document-template-editor-head h2{font-size:19px}.document-template-editor-tabs{padding:8px 10px}.document-template-editor-toolbar{padding:8px 10px;gap:7px}.template-editor-hint{width:100%;margin-left:0}.template-insert-field{width:100%}.template-insert-field select{flex:1;min-width:0}.document-template-editor-workspace{padding:12px;overflow:auto}.document-template-paper{width:720px;min-height:1018px;transform-origin:top left;padding:58px 58px}.document-template-editor-footer{padding:9px 10px}.document-template-editor-footer button{flex:1}.template-page-break{margin-left:-58px;margin-right:-58px}}
@media(max-width:480px){.document-template-paper{width:650px;min-height:920px;font-size:13px}.document-template-editor-toolbar .template-mode-switch{width:100%}.template-mode-switch button{flex:1}.document-template-editor-tabs button{padding:8px 10px;font-size:12px}}
@media(max-width:820px){.document-template-paper{width:100%;min-width:0;min-height:calc((100vw - 24px)*1.414);padding:38px 28px;font-size:12px}.template-page-break{margin-left:-28px;margin-right:-28px}.template-signatures{gap:24px}.template-paper-title{font-size:18px}.template-commercial-meta{grid-template-columns:150px 1fr}}
@media(max-width:480px){.document-template-paper{width:100%;min-height:calc((100vw - 24px)*1.414);padding:30px 20px;font-size:11px}.template-page-break{margin-left:-20px;margin-right:-20px}.template-paper-table{font-size:9px}.template-paper-table th,.template-paper-table td{padding:4px}.template-commercial-meta{grid-template-columns:115px 1fr}.template-signatures{grid-template-columns:1fr;gap:20px}}

/* ===== v16.83 — крупная и аккуратная верхняя мобильная навигация ===== */
@media(max-width:768px){
  #mobilePersistentTabs.mobile-persistent-tabs{
    gap:7px!important;
    padding:8px 7px 9px!important;
    background:#f7f9fc!important;
    border-bottom:1px solid #e1e7ef!important;
    box-shadow:0 5px 16px rgba(26,39,58,.06)!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs > button{
    min-height:68px!important;
    padding:8px 3px 7px!important;
    border:1px solid #e2e8f0!important;
    border-radius:15px!important;
    background:#fff!important;
    color:#536172!important;
    font-size:11.5px!important;
    line-height:1.08!important;
    font-weight:850!important;
    box-shadow:0 2px 7px rgba(25,39,58,.055)!important;
    transition:transform .12s ease,box-shadow .12s ease,background .12s ease,color .12s ease,border-color .12s ease!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs > button span{
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    width:32px!important;
    height:32px!important;
    margin:0 auto 2px!important;
    border-radius:10px!important;
    background:#f1f4f8!important;
    color:#58677a!important;
    font-size:21px!important;
    line-height:1!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs > button.active{
    background:#1769e0!important;
    border-color:#1769e0!important;
    color:#fff!important;
    box-shadow:0 7px 18px rgba(23,105,224,.22)!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs > button.active span{
    background:rgba(255,255,255,.18)!important;
    color:#fff!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs > button:active{transform:scale(.97)!important}
}
@media(max-width:380px){
  #mobilePersistentTabs.mobile-persistent-tabs{gap:4px!important;padding-left:4px!important;padding-right:4px!important}
  #mobilePersistentTabs.mobile-persistent-tabs > button{min-height:64px!important;font-size:10.5px!important;border-radius:13px!important}
  #mobilePersistentTabs.mobile-persistent-tabs > button span{width:29px!important;height:29px!important;font-size:19px!important}
}
@media (orientation:landscape) and (max-height:600px) and (max-width:1100px){
  #mobilePersistentTabs.mobile-persistent-tabs{gap:7px!important;padding:6px 8px!important;background:#f7f9fc!important}
  #mobilePersistentTabs.mobile-persistent-tabs > button{min-height:56px!important;border:1px solid #e2e8f0!important;border-radius:13px!important;background:#fff!important;color:#536172!important;font-size:11px!important;box-shadow:0 2px 7px rgba(25,39,58,.055)!important}
  #mobilePersistentTabs.mobile-persistent-tabs > button span{width:27px!important;height:27px!important;font-size:18px!important;background:#f1f4f8!important;color:#58677a!important}
  #mobilePersistentTabs.mobile-persistent-tabs > button.active{background:#1769e0!important;border-color:#1769e0!important;color:#fff!important;box-shadow:0 6px 16px rgba(23,105,224,.20)!important}
  #mobilePersistentTabs.mobile-persistent-tabs > button.active span{background:rgba(255,255,255,.18)!important;color:#fff!important}
}








/* ===== v16.86 — branded blue pictogram icons for primary mobile tabs ===== */

#mobilePersistentTabs .ais-tab-icon{
  width:31px!important;
  height:31px!important;
  display:block;
  overflow:visible;
  filter:drop-shadow(0 2px 2px rgba(6,75,166,.13));
}
#mobilePersistentTabs .ais-tab-icon .icon-paper-front,
#mobilePersistentTabs .ais-tab-icon .icon-paper-back,
#mobilePersistentTabs .ais-tab-icon .icon-hammer-head,
#mobilePersistentTabs .ais-tab-icon .icon-cube,
#mobilePersistentTabs .ais-tab-icon .icon-pencil{
  fill:url(#tabBlue1);
  stroke:#0754bd;
  stroke-width:1.2;
  stroke-linejoin:round;
}
#mobilePersistentTabs .ais-tab-icon-current .icon-paper-front,
#mobilePersistentTabs .ais-tab-icon-current .icon-pencil{fill:url(#tabBlue2)}
#mobilePersistentTabs .ais-tab-icon-works .icon-hammer-head{fill:url(#tabBlue3)}
#mobilePersistentTabs .ais-tab-icon-materials .icon-cube{fill:url(#tabBlue4)}
#mobilePersistentTabs .ais-tab-icon .icon-paper-back{opacity:.28}
#mobilePersistentTabs .ais-tab-icon .icon-fold,
#mobilePersistentTabs .ais-tab-icon .icon-line,
#mobilePersistentTabs .ais-tab-icon .icon-table-line,
#mobilePersistentTabs .ais-tab-icon .icon-pencil-tip,
#mobilePersistentTabs .ais-tab-icon .icon-hammer-shine{
  fill:none;
  stroke:#fff;
  stroke-width:1.45;
  stroke-linecap:round;
  stroke-linejoin:round;
}
#mobilePersistentTabs .ais-tab-icon .icon-table{
  fill:#fff;
  stroke:#0754bd;
  stroke-width:1.05;
}
#mobilePersistentTabs .ais-tab-icon-materials .icon-cube-side{
  fill:#0b77e6;
  stroke:#0754bd;
  stroke-width:1.05;
  stroke-linejoin:round;
}
#mobilePersistentTabs .ais-tab-icon-materials .icon-cube-side2{
  fill:#075dcc;
  stroke:#0754bd;
  stroke-width:1.05;
  stroke-linejoin:round;
}

#mobilePersistentTabs.mobile-persistent-tabs > button.active .ais-tab-icon{
  filter:drop-shadow(0 2px 3px rgba(0,58,151,.20));
}
@media(max-width:380px){
  
  #mobilePersistentTabs .ais-tab-icon{width:27px!important;height:27px!important}
}
@media (orientation:landscape) and (max-height:600px) and (max-width:1100px){
  
  #mobilePersistentTabs .ais-tab-icon{width:24px!important;height:24px!important}
}

/* ===== v16.86 — unified AI Smeta blue card interface ===== */
:root{
  --ais-blue:#0877ed;
  --ais-blue-deep:#0757d4;
  --ais-cyan:#20b8ff;
  --ais-ink:#162a43;
  --ais-muted:#74849a;
  --ais-border:#e2eaf4;
  --ais-surface:#ffffff;
  --ais-canvas:#f7faff;
  --ais-soft-blue:#eef6ff;
  --ais-card-shadow:0 10px 28px rgba(31,75,122,.08);
}
body{background:linear-gradient(180deg,#fff 0,#f8fbff 210px,#f6f9fd 100%)!important;color:var(--ais-ink)!important}
header{
  min-height:78px!important;padding:13px 24px!important;background:rgba(255,255,255,.94)!important;
  border-bottom:1px solid var(--ais-border)!important;box-shadow:0 5px 20px rgba(27,73,120,.045)!important;
}
.brand{font-size:27px!important;font-weight:800!important;color:#1d2733!important;display:flex;align-items:baseline;gap:5px}
.brand span{font-size:31px!important;font-weight:900!important;background:linear-gradient(145deg,#0b5ed8,#16b6ff);-webkit-background-clip:text;background-clip:text;color:transparent!important}
.brand small{font-size:10px!important;letter-spacing:.02em!important}
header .btn-light,header .file-menu-button{
  min-height:44px!important;border-radius:13px!important;border:1px solid var(--ais-border)!important;
  color:#096ee0!important;background:#fff!important;box-shadow:0 4px 12px rgba(35,81,126,.055)!important;
}
.layout{max-width:1540px!important;gap:22px!important;padding-top:22px!important}
aside{width:225px!important;background:#fff!important;border:1px solid var(--ais-border)!important;border-radius:20px!important;padding:12px!important;height:max-content;box-shadow:var(--ais-card-shadow)!important}
nav{top:100px!important;gap:5px!important}
nav button{min-height:46px!important;border-radius:12px!important;padding:12px 14px!important;color:#52657b!important;font-weight:650!important}
nav button:hover{background:#f4f8fd!important;color:#096ee0!important}
nav button.active{background:linear-gradient(90deg,#eaf4ff,#f5f9ff)!important;color:#0875e9!important;box-shadow:none!important}
main{padding:0!important}
.view.active{display:block}
.view h1,.estimates-hub-head h1{color:var(--ais-ink)!important;font-weight:800!important;letter-spacing:-.035em!important}
.card, .estimates-search-card, .subscription-card{
  border:1px solid var(--ais-border)!important;border-radius:20px!important;background:#fff!important;box-shadow:var(--ais-card-shadow)!important;
}
.estimates-hub-head{margin-bottom:16px!important}
.estimates-hub-actions{margin-bottom:16px!important}
.ai-main-create-btn{
  min-height:66px!important;border-radius:16px!important;background:linear-gradient(135deg,#0759db 0%,#0787f4 62%,#20b8ff 100%)!important;
  border:1px solid rgba(0,93,213,.25)!important;box-shadow:0 12px 26px rgba(5,105,226,.20)!important;font-size:19px!important;
}
.btn{background:linear-gradient(135deg,#0764e7,#0a8ff5)!important;border-radius:12px!important;box-shadow:0 5px 12px rgba(5,104,226,.13)!important}
.btn-light,.btn-danger,.btn-ok{border-radius:12px!important}
input,select,textarea{border:1px solid #dbe5f0!important;border-radius:12px!important;background:#fff!important;min-height:42px}
input:focus,select:focus,textarea:focus{border-color:#1689f4!important;box-shadow:0 0 0 4px rgba(22,137,244,.10)!important}
table{border:1px solid #e4ebf3!important;border-radius:15px!important;background:#fff!important;box-shadow:0 4px 14px rgba(35,75,118,.035)!important}
thead th{background:#f7faff!important;color:#72839a!important;padding-top:12px!important;padding-bottom:12px!important}
tbody td{padding-top:12px!important;padding-bottom:12px!important}
tbody tr:hover td{background:#fbfdff!important}
.file-menu-dropdown, .ais-dialog-card{border:1px solid var(--ais-border)!important;border-radius:18px!important;box-shadow:0 22px 55px rgba(22,61,104,.16)!important}

/* The four primary destinations use the same visual language as the approved mock-up. */
#mobilePersistentTabs.mobile-persistent-tabs{
  background:#fff!important;border:1px solid var(--ais-border)!important;border-radius:20px!important;
  box-shadow:0 8px 24px rgba(28,73,120,.075)!important;
}
#mobilePersistentTabs.mobile-persistent-tabs > button{
  background:#fff!important;border:1px solid #e3eaf3!important;color:#253a54!important;border-radius:16px!important;
}
#mobilePersistentTabs.mobile-persistent-tabs > button.active{
  background:linear-gradient(135deg,#0758da 0%,#0787f3 64%,#1db7ff 100%)!important;border-color:#0877ed!important;color:#fff!important;
  box-shadow:0 9px 22px rgba(5,104,226,.22)!important;
}



@media(min-width:769px){
  /* Keep existing desktop navigation functional, but surface the four key destinations as a dashboard strip. */
  #mobilePersistentTabs.mobile-persistent-tabs{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px!important;position:relative!important;top:auto!important;left:auto!important;right:auto!important;z-index:10!important;margin:18px auto 0!important;max-width:1484px!important;padding:12px!important}
  #mobilePersistentTabs.mobile-persistent-tabs > button{display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:center!important;min-height:118px!important;font-size:16px!important;font-weight:800!important;gap:7px!important}
  
  #mobilePersistentTabs .ais-tab-icon{width:40px!important;height:40px!important}
  .layout{padding-top:20px!important}
}
@media(max-width:768px){
  header{min-height:60px!important;padding:9px 12px!important}
  
  .mobile-brand{color:var(--ais-ink)!important;font-weight:800!important}
  #mobilePersistentTabs.mobile-persistent-tabs{padding:7px!important;gap:6px!important;border-radius:0!important;border-left:0!important;border-right:0!important}
  #mobilePersistentTabs.mobile-persistent-tabs > button{min-height:76px!important;border-radius:14px!important;font-size:11px!important;gap:2px!important}
  
  #mobilePersistentTabs .ais-tab-icon{width:29px!important;height:29px!important}
  main{padding:12px!important}
  .card{border-radius:16px!important;padding:15px!important}
  .ai-main-create-btn{min-height:60px!important;border-radius:15px!important;font-size:17px!important}
}

/* ===== v16.87 — documents sheet works from Estimates on desktop and mobile ===== */
#mobileDocumentsOverlay.open{
  display:flex!important;
}
@media (min-width:769px){
  #mobileDocumentsOverlay{
    position:fixed;
    inset:0;
    z-index:50020;
    background:rgba(17,24,39,.38);
    align-items:center;
    justify-content:center;
    padding:24px;
    box-sizing:border-box;
  }
  #mobileDocumentsOverlay .mobile-more-sheet{
    display:block;
    width:min(760px,calc(100vw - 48px));
    max-height:min(820px,calc(100vh - 48px));
    overflow:auto;
    background:#fff;
    border:1px solid #e5ebf4;
    border-radius:24px;
    padding:18px 20px 22px;
    box-sizing:border-box;
    box-shadow:0 24px 70px rgba(15,42,80,.20);
  }
  #mobileDocumentsOverlay .mobile-sheet-handle{display:none}
  #mobileDocumentsOverlay .mobile-sheet-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:16px;
    margin-bottom:16px;
  }
  #mobileDocumentsOverlay .mobile-sheet-title{
    font-size:22px;
    line-height:1.2;
    font-weight:800;
    color:#172033;
  }
  #mobileDocumentsOverlay .mobile-sheet-close{
    width:40px;
    height:40px;
    border:1px solid #dce5f0;
    border-radius:12px;
    background:#fff;
    color:#526274;
    font-size:26px;
    line-height:1;
    cursor:pointer;
  }
  #mobileDocumentsOverlay .mobile-action-section{
    display:grid;
    grid-template-columns:minmax(210px,1fr) auto;
    align-items:center;
    gap:16px;
    padding:14px 0;
    border-top:1px solid #edf1f6;
  }
  #mobileDocumentsOverlay .mobile-doc-first{border-top:0}
  #mobileDocumentsOverlay .mobile-action-title{
    font-weight:750;
    color:#24344a;
  }
  #mobileDocumentsOverlay .mobile-export-row{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    justify-content:flex-end;
  }
  #mobileDocumentsOverlay .mobile-export-row button{
    min-width:74px;
    min-height:40px;
    padding:8px 13px;
    border:1px solid #dbe6f5;
    border-radius:12px;
    background:#f8fbff;
    color:#1769e0;
    font-weight:750;
    cursor:pointer;
  }
  #mobileDocumentsOverlay .mobile-export-row button:hover{
    background:#edf5ff;
    border-color:#c9dcf7;
  }
}


/* ===== v16.89 — interactive onboarding tour ===== */
.ais-onboarding-tour{display:none;position:fixed;inset:0;z-index:300000;pointer-events:none}
.ais-onboarding-tour.open{display:block}
.ais-tour-backdrop{position:absolute;inset:0;background:rgba(10,25,48,.58);backdrop-filter:saturate(.9);pointer-events:auto}
.ais-tour-target{pointer-events:none!important}
.ais-tour-highlight{display:none;position:fixed;z-index:300030;box-sizing:border-box;border:4px solid #fff;border-radius:16px;box-shadow:0 0 0 4px rgba(28,126,244,.9),0 14px 38px rgba(7,45,95,.32);pointer-events:none}
.ais-tour-highlight.show{display:block;animation:aisTourHighlightPulse 1.25s ease-in-out infinite}
@keyframes aisTourHighlightPulse{0%,100%{box-shadow:0 0 0 4px rgba(28,126,244,.9),0 14px 38px rgba(7,45,95,.32)}50%{box-shadow:0 0 0 7px rgba(28,126,244,.55),0 16px 44px rgba(7,45,95,.38)}}

.ais-tour-menu-target{scroll-margin-top:96px;scroll-margin-bottom:96px}
.ais-tour-pointer{display:none;position:fixed;z-index:300035;width:42px;height:50px;pointer-events:none;filter:drop-shadow(0 5px 7px rgba(2,58,132,.28))}
.ais-tour-pointer.show{display:block;animation:aisTourPointerBob .85s ease-in-out infinite alternate}
.ais-tour-pointer span{position:absolute;left:14px;top:1px;width:14px;height:31px;border-radius:999px;background:linear-gradient(180deg,#5db9ff,#0874ea)}
.ais-tour-pointer span:after{content:"";position:absolute;left:-9px;bottom:-6px;width:0;height:0;border-left:16px solid transparent;border-right:16px solid transparent;border-top:18px solid #0874ea}
.ais-tour-pointer.up{transform:rotate(180deg)}
@keyframes aisTourPointerBob{from{margin-top:-2px}to{margin-top:5px}}
.ais-tour-card{position:fixed;z-index:300040;box-sizing:border-box;overflow:auto;background:#fff;border:1px solid rgba(26,96,190,.15);border-radius:22px;padding:22px 22px 18px;box-shadow:0 24px 70px rgba(4,32,70,.28);pointer-events:auto;color:#17243a;overscroll-behavior:contain}
.ais-tour-progress{position:absolute;right:48px;top:18px;font-size:12px;font-weight:800;color:#7b8aa0;background:#f2f6fb;border-radius:999px;padding:4px 9px}
.ais-tour-close{position:absolute;right:13px;top:11px;width:32px;height:32px;border:0;border-radius:50%;background:#f1f5f9;color:#65758b;font-size:22px;line-height:30px;cursor:pointer}
.ais-tour-kicker{font-size:11px;font-weight:900;letter-spacing:.08em;text-transform:uppercase;color:#1778e8;margin-bottom:7px}
.ais-tour-card h3{font-size:21px;line-height:1.16;margin:0 0 9px;color:#10233f;padding-right:80px}
.ais-tour-text{font-size:14px;line-height:1.5;color:#52647c}
.ais-tour-actions{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:18px;padding-top:15px;border-top:1px solid #e9eff6}
.ais-tour-nav-actions{display:flex;gap:8px}
.ais-tour-actions button{min-height:40px;padding:9px 15px;border-radius:12px;font-weight:800;cursor:pointer}
.ais-tour-skip,.ais-tour-prev{border:1px solid #d8e1ec;background:#fff;color:#52647c}
.ais-tour-prev:disabled{opacity:.38;cursor:default}
.ais-tour-next{border:0;background:linear-gradient(135deg,#2696ff,#0868dc);color:#fff;box-shadow:0 8px 18px rgba(20,119,229,.22)}
body.ais-tour-open{overflow:hidden!important}
@media(max-width:560px){
 .ais-tour-card{border-radius:19px;padding:19px 17px 15px;max-height:calc(100dvh - 24px)}
 .ais-tour-card h3{font-size:19px;padding-right:72px}
 .ais-tour-text{font-size:13.5px}
 .ais-tour-actions{align-items:stretch}
 .ais-tour-actions button{padding-left:12px;padding-right:12px}
 .ais-tour-skip{font-size:12px}
}

/* ===== v16.91 — cleaner estimate-name wizard step ===== */
.ai-wizard-main-input{
  display:block;
  width:100%;
  box-sizing:border-box;
  margin-top:12px;
}


/* v16.91 — detailed training menu */
.ais-training-menu{max-width:620px!important}
.ais-training-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:18px}
.ais-training-grid button{display:flex;flex-direction:column;align-items:flex-start;gap:5px;padding:18px;border:1px solid #dbe7f5;border-radius:16px;background:linear-gradient(180deg,#fff,#f7fbff);color:#163354;text-align:left;cursor:pointer;box-shadow:0 6px 18px rgba(21,85,153,.07)}
.ais-training-grid button:hover{border-color:#79b8ff;transform:translateY(-1px)}
.ais-training-grid b{font-size:16px}.ais-training-grid span{font-size:12px;color:#72849a}
@media(max-width:600px){.ais-training-grid{grid-template-columns:1fr}.ais-training-grid button{padding:15px}.ais-training-menu{width:calc(100vw - 20px)!important;max-height:88vh;overflow:auto}}


/* ===== v16.92 — full training CTA ===== */
.ais-training-full{width:100%;border:0;border-radius:18px;padding:18px 20px;margin:4px 0 18px;background:linear-gradient(135deg,#1478ff,#075bd8);color:#fff;display:flex;align-items:center;gap:14px;text-align:left;box-shadow:0 12px 28px rgba(20,120,255,.24);cursor:pointer}
.ais-training-full:hover{transform:translateY(-1px);box-shadow:0 15px 32px rgba(20,120,255,.3)}
.ais-training-full-icon{font-size:30px;line-height:1}
.ais-training-full>span:nth-child(2){display:flex;flex:1;flex-direction:column;gap:3px}
.ais-training-full b{font-size:16px}.ais-training-full small{font-size:12px;color:rgba(255,255,255,.8)}
.ais-training-full-arrow{font-size:25px;font-weight:800}.ais-training-divider{display:flex;align-items:center;gap:10px;margin:0 0 12px;color:#7b8798;font-size:12px;font-weight:700}
.ais-training-divider:before,.ais-training-divider:after{content:"";height:1px;background:#e5eaf1;flex:1}
@media(max-width:600px){.ais-training-full{padding:17px 16px;border-radius:16px}.ais-training-full-icon{font-size:27px}}

/* v16.95 — current estimate details + searchable work picker */
.estimate-details-toggle{width:100%;display:flex;align-items:center;gap:10px;border:0;background:transparent;padding:0;color:var(--text);font:inherit;font-size:18px;font-weight:800;text-align:left;cursor:pointer}
.estimate-details-plus{width:28px;height:28px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;background:#edf4ff;color:#1769d2;font-size:22px;line-height:1;transition:.18s}
.estimate-details-toggle[aria-expanded="true"] .estimate-details-plus{transform:rotate(45deg)}
.estimate-details-body{padding-top:16px}
.estimate-open-work-picker{min-height:46px;padding-inline:20px}
.estimate-work-picker{width:min(760px,100%)}
.estimate-work-search{width:100%;font-size:16px;padding:13px 14px;margin:12px 0}
.estimate-work-results{display:grid;gap:8px;max-height:55vh;overflow:auto;padding:2px}
.estimate-work-option{display:grid;grid-template-columns:1fr auto;gap:8px 14px;align-items:center;width:100%;padding:13px 14px;border:1px solid var(--line);border-radius:13px;background:#fff;text-align:left;cursor:pointer}
.estimate-work-option:hover{border-color:#9fc5ff;background:#f7fbff}.estimate-work-option b{font-size:14px}.estimate-work-option small{color:var(--muted)}
.estimate-work-option-price{font-weight:800;white-space:nowrap;color:#1769d2}
@media(max-width:560px){.estimate-details-toggle{font-size:17px}.estimate-open-work-picker{width:100%;min-height:52px}.estimate-work-picker{height:min(86vh,760px)}.estimate-work-results{max-height:62vh}.estimate-work-option{grid-template-columns:1fr}.estimate-work-option-price{font-size:13px}}


/* v16.95 — reorder estimate rows + rich new work creator */
.estimate-row-actions{display:flex;align-items:center;justify-content:flex-end;gap:5px;white-space:nowrap}
.estimate-move-btn{width:30px;height:30px;border:1px solid #cbd8ea;border-radius:9px;background:#f7faff;color:#1769d2;font-size:17px;font-weight:900;line-height:1;cursor:pointer;transition:.16s ease}
.estimate-move-btn:hover{background:#eaf3ff;border-color:#8fb9f2;transform:translateY(-1px)}
.estimate-work-picker-tools{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:center;margin:12px 0}
.estimate-work-picker-tools .estimate-work-search{margin:0}
.estimate-new-work-btn{min-height:46px;white-space:nowrap}
.estimate-new-work-creator{max-height:70vh;overflow:auto;padding:3px 2px 4px}
.estimate-new-work-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:12px 0 16px}
.estimate-new-work-grid label{display:flex;flex-direction:column;gap:6px;font-size:12px;font-weight:750;color:var(--muted)}
.estimate-new-work-grid input{width:100%;font-size:15px}
.estimate-new-work-section{border:1px solid var(--line);border-radius:15px;background:#fbfdff;padding:13px;margin-top:12px}
.estimate-new-work-section-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px}
.estimate-new-work-section-head b{font-size:15px;color:var(--text)}
.estimate-new-work-head-actions{display:flex;gap:7px;flex-wrap:wrap;justify-content:flex-end}
.estimate-new-work-row{display:grid;grid-template-columns:minmax(170px,2fr) minmax(74px,.65fr) minmax(88px,.7fr) minmax(105px,.85fr) 38px;gap:7px;align-items:center;margin-top:8px}
.estimate-new-material-row{display:grid;grid-template-columns:minmax(210px,1fr) minmax(140px,.42fr) 38px;gap:8px;align-items:end;margin-top:8px}
.estimate-new-material-rate{display:grid;grid-template-columns:auto 1fr;gap:7px;align-items:center;font-size:12px;color:var(--muted)}
.estimate-new-material-row select,.estimate-new-material-row input,.estimate-new-work-row input{min-height:40px}
.estimate-new-work-actions{position:sticky;bottom:-4px;display:flex;justify-content:space-between;gap:10px;margin-top:16px;padding:12px 0 2px;background:linear-gradient(to bottom,rgba(255,255,255,0),#fff 18%,#fff)}
@media(max-width:700px){
 .estimate-row-actions{gap:3px}.estimate-move-btn{width:28px;height:28px;border-radius:8px}
 .estimate-work-picker-tools{grid-template-columns:1fr}.estimate-new-work-btn{width:100%}
 .estimate-new-work-creator{max-height:68vh}.estimate-new-work-grid{grid-template-columns:1fr}
 .estimate-new-work-section-head{align-items:flex-start;flex-direction:column}.estimate-new-work-head-actions{width:100%;justify-content:flex-start}.estimate-new-work-head-actions .btn-light{flex:1}
 .estimate-new-work-row{grid-template-columns:1fr 76px}.estimate-new-work-row input[data-field="name"]{grid-column:1/-1}.estimate-new-work-row .btn-danger{grid-column:2;justify-self:end}
 .estimate-new-material-row{grid-template-columns:1fr 38px}.estimate-new-material-row select{grid-column:1/-1}.estimate-new-work-actions{flex-direction:column-reverse}.estimate-new-work-actions button{width:100%;min-height:48px}
}
/* Keep the standard library editor above the estimate work creator when a new material is created from it. */
#itemModal.open{z-index:60010!important}


/* ===== v16.98 — grouped work picker + contextual primary navigation ===== */
.estimate-work-category{border:1px solid #e1e8f2;border-radius:15px;background:#fff;overflow:hidden;box-shadow:0 2px 8px rgba(22,42,70,.035)}
.estimate-work-category+.estimate-work-category{margin-top:8px}
.estimate-work-category-head{width:100%;display:grid;grid-template-columns:34px 1fr auto;align-items:center;gap:9px;padding:13px 14px;border:0;background:#f7faff;color:#172334;text-align:left;cursor:pointer;font:inherit}
.estimate-work-category-head:hover{background:#f0f6ff}
.estimate-work-category-plus{width:28px;height:28px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;background:#e8f2ff;color:#0d6fe8;font-size:22px;font-weight:700;line-height:1}
.estimate-work-category-title{font-weight:850;font-size:14px}
.estimate-work-category-count{min-width:28px;padding:3px 8px;border-radius:999px;background:#eaf0f8;color:#65758a;font-size:11px;font-weight:800;text-align:center}
.estimate-work-category.open .estimate-work-category-head{border-bottom:1px solid #e8eef6;background:#f4f8ff}
.estimate-work-category-body{display:grid;gap:7px;padding:9px}
.estimate-work-category-body[hidden]{display:none!important}
.estimate-work-category .estimate-work-option{border-radius:11px;box-shadow:none}
@media(max-width:768px){#mobilePersistentTabs.mobile-persistent-tabs.three-primary-tabs{grid-template-columns:repeat(3,minmax(0,1fr))!important}.estimate-work-category-head{padding:12px 10px;grid-template-columns:32px 1fr auto}.estimate-work-category-title{font-size:13px}}
@media(min-width:769px){#mobilePersistentTabs.mobile-persistent-tabs.three-primary-tabs{grid-template-columns:repeat(3,minmax(0,1fr))!important}}


/* ===== v16.98 — three full-width mobile tabs + current estimate hierarchy ===== */
.context-hidden{display:none!important}
@media (max-width:768px){
  #mobilePersistentTabs.mobile-persistent-tabs.three-primary-tabs{
    display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    width:100%!important;
    max-width:100%!important;
    box-sizing:border-box!important;
    gap:8px!important;
    padding:8px 10px!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs.three-primary-tabs > button:not(.context-hidden){
    display:flex!important;
    width:100%!important;
    min-width:0!important;
    min-height:72px!important;
    padding:7px 4px!important;
    font-size:12px!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs.three-primary-tabs > button.context-hidden{display:none!important}
}
@media(max-width:380px){
  #mobilePersistentTabs.mobile-persistent-tabs.three-primary-tabs{gap:5px!important;padding-left:6px!important;padding-right:6px!important}
  #mobilePersistentTabs.mobile-persistent-tabs.three-primary-tabs > button:not(.context-hidden){min-height:68px!important;font-size:11px!important}
}
@media (orientation:landscape) and (max-height:600px) and (max-width:1100px){
  #mobilePersistentTabs.mobile-persistent-tabs.three-primary-tabs{
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    gap:8px!important;
    padding:6px 10px!important;
  }
  #mobilePersistentTabs.mobile-persistent-tabs.three-primary-tabs > button:not(.context-hidden){display:flex!important;width:100%!important}
  #mobilePersistentTabs.mobile-persistent-tabs.three-primary-tabs > button.context-hidden{display:none!important}
}
.estimate-back-row{margin:0 0 10px}
.estimate-back-btn{
  min-height:38px;
  padding:8px 12px;
  color:#075fce!important;
  background:#eef6ff!important;
  border:1px solid #b9d7fb!important;
  border-radius:11px!important;
  font-weight:850!important;
  box-shadow:0 2px 7px rgba(19,101,194,.07)!important;
}
.estimate-back-btn:hover{background:#e3f0ff!important;border-color:#86baf5!important;color:#064fa9!important}
.estimate-ai-actions{margin-top:0!important}

/* ===== Строй ОС v21.70 — mobile: tasks ===== */
@media(max-width:768px){
 .task-card{grid-template-columns:32px minmax(0,1fr);padding:13px}
 .task-card-actions{grid-column:2;justify-content:flex-start;flex-wrap:wrap}
 .task-card-actions button{min-height:38px}
}


/* ===== Строй ОС v21.73 — mobile: object expenses ===== */
@media(max-width:768px){
  .expense-card{
    grid-template-columns:1fr auto;
    gap:7px 10px;
    padding:13px;
  }
  .expense-date{grid-column:1;padding:0;font-size:12px}
  .expense-main{grid-column:1/-1}
  .expense-amount{margin:2px 0 9px;font-size:24px}
  .expense-actions{
    display:grid;
    grid-column:1/-1;
    grid-template-columns:1fr 1fr;
    margin-top:5px;
  }
  .expense-actions button{
    width:100%;
    min-height:38px;
  }
}


/* ===== Строй ОС v21.72 — mobile: object receipts ===== */
@media(max-width:700px){
  .receipt-ai-row{align-items:stretch;flex-direction:column}
}


/* ===== Строй ОС v21.71 — mobile: object materials ===== */
@media(max-width:700px){
  .material-status-actions select{width:100%}
}


/* ===== Строй ОС v21.69 — mobile: object resources ===== */
@media(max-width:440px){
  .ai-home-resource-actions{grid-template-columns:1fr}
  .ai-home-resource-toggle{padding:13px 12px}
  .ai-home-resource-item{grid-template-columns:34px minmax(0,1fr) auto}
  .ai-home-resource-item-actions button{width:29px;height:29px}
}
@media(min-width:769px){
  .ai-home-resource-panel{margin-top:12px;border-radius:18px}
  .ai-home-resource-toggle{min-height:66px}
  .ai-home-resource-actions{grid-template-columns:1fr 1fr}
}


/* ===== Строй ОС v21.68 — mobile: objects list/cards ===== */
@media(max-width:680px){
  .current-object-block{margin-bottom:20px}
  .other-objects-list{gap:9px}
  .object-card{
    grid-template-columns:46px minmax(0,1fr);
    padding:14px;
  }
  .object-card-icon{
    width:44px;
    height:44px;
    border-radius:13px;
    font-size:23px;
  }
  .object-card-actions{
    grid-column:1/-1;
    justify-content:flex-end;
  }
  .object-card-actions>span{display:none}
  .current-object-card .object-card-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
  }
  .current-object-card .object-card-actions button{width:100%}
}
@media(max-width:560px){
  .object-card-tabs{
    gap:3px;
    margin-bottom:14px;
    padding:4px;
  }
  .object-card-tabs button{
    min-height:39px;
    padding:6px 3px;
    font-size:11px;
  }
}
@media(min-width:769px){
  #objectsList .other-objects-list{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:14px;
  }
  #objects .tasks-head{align-items:center}
  #objects .tasks-head .btn{min-width:154px}
}


/* ===== Строй ОС v21.67 — mobile: settings ===== */
@media(max-width:768px){
  .settings-tabs{
    width:100%;
    box-sizing:border-box;
    gap:4px;
    padding:4px;
    border-radius:12px;
  }
  .settings-tab{
    flex:1;
    min-width:0;
    min-height:44px;
    padding:7px 6px;
    font-size:13px;
    line-height:1.12;
  }
  #settingsTabRequisites{font-size:12px}
  .api-key-create-row{grid-template-columns:1fr}
  .api-key-secret{align-items:stretch;flex-direction:column}
  .api-key-row{align-items:flex-start;flex-direction:column}
}


/* ===== Строй ОС v21.66 — mobile: modal system ===== */
@media(max-width:768px){
  .modal{
    align-items:flex-end;
    justify-content:center;
    padding:
      max(10px,env(safe-area-inset-top))
      max(10px,env(safe-area-inset-right))
      max(10px,env(safe-area-inset-bottom))
      max(10px,env(safe-area-inset-left));
  }
  .modal-box{
    width:100%;
    max-width:100%;
    max-height:calc(100dvh - 20px);
    margin:0;
    border-radius:22px 22px 16px 16px;
  }
  .stroy-app-overlay-dialog{
    align-items:flex-start;
    padding:
      max(14px,env(safe-area-inset-top))
      12px
      max(24px,calc(env(safe-area-inset-bottom) + 20px));
  }
  .stroy-app-dialog-card{
    width:100%;
    max-height:none;
    margin:0;
    padding:22px 16px;
  }
}
@supports not (height:100dvh){
  .modal-box{max-height:calc(100vh - 36px)}
  @media(max-width:768px){
    .modal-box{max-height:calc(100vh - 20px)}
  }
}


/* ===== Строй ОС v21.65 — mobile: object wizard ===== */
@media(max-width:720px){
  #objectWizardModal{
    align-items:flex-start;
    justify-content:center;
    overflow:hidden;
    padding:
      max(10px,env(safe-area-inset-top))
      10px
      max(10px,env(safe-area-inset-bottom));
  }
  .object-wizard-box{
    width:100%;
    max-width:680px;
    height:auto;
    max-height:calc(100dvh - max(20px,env(safe-area-inset-top)) - max(20px,env(safe-area-inset-bottom)));
    margin:0;
    padding:18px 16px 18px;
    border-radius:22px;
    overflow-y:auto;
    overflow-x:hidden;
    scroll-padding-top:88px;
    scroll-padding-bottom:96px;
    -webkit-overflow-scrolling:touch;
  }
  .object-wizard-head{
    top:-18px;
    margin:-18px -16px 0;
    padding:18px 16px 12px;
  }
  .object-wizard-progress{
    margin:0 -4px 18px;
    padding:12px 4px 8px;
    gap:6px;
  }
  .object-wizard-progress-item b{display:none}
  .object-wizard-progress-line{min-width:16px}
  .object-wizard-step h3{font-size:23px}
  .object-wizard-ai-choice{grid-template-columns:1fr}
  .object-wizard-inline-form{grid-template-columns:1fr 1fr}
  .object-wizard-inline-form .btn{grid-column:1/-1}
  .object-wizard-material-form{grid-template-columns:1fr 100px}
  .object-wizard-material-form .btn{grid-column:1/-1}
  .object-wizard-actions{
    position:sticky;
    bottom:-18px;
    z-index:3;
    margin:20px -16px -18px;
    padding:12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top:1px solid var(--border,#dfe5ec);
    background:var(--panel,#fff);
  }
  .object-wizard-actions-end .btn{margin-left:auto}
  .object-wizard-step .form-grid{gap:14px}
  .object-wizard-step .form-grid label{gap:7px}
  .object-wizard-step input,
  .object-wizard-step select,
  .object-wizard-step textarea{scroll-margin-top:94px;scroll-margin-bottom:110px}
}

/* При открытой экранной клавиатуре visual viewport обычно становится ниже.
   dvh заставляет мастер ужаться и прокручиваться внутри окна, а не уходить под клавиатуру. */
@media(max-width:720px) and (max-height:620px){
  #objectWizardModal{padding-top:6px;padding-bottom:6px}
  .object-wizard-box{
    max-height:calc(100dvh - 12px);
    border-radius:18px;
    padding-top:14px;
  }
  .object-wizard-head{
    top:-14px;
    margin-top:-14px;
    padding-top:14px;
  }
  .object-wizard-progress{margin-bottom:10px;padding-top:8px}
  .object-wizard-help{margin-bottom:12px}
}



/* ===== Строй ОС v21.76 — mobile: More sheet above persistent tabs ===== */
@media(max-width:768px){
  #mobileMoreOverlay.mobile-more-overlay{
    inset:0 0 calc(70px + env(safe-area-inset-bottom)) 0;
    z-index:50000!important;
  }
  #mobileMoreOverlay .mobile-more-sheet{
    max-height:calc(100dvh - 86px - env(safe-area-inset-bottom));
    overscroll-behavior:contain;
    padding-bottom:22px;
  }
}


/* ===== Строй ОС v21.77 — mobile More sheet above persistent tabs ===== */
@media(max-width:768px){
  /*
   * Bottom navigation is fixed and must never cover the More sheet.
   * Keep the overlay above the persistent tabs and reserve the real tab height
   * (including the device safe-area) below the sheet.
   */
  #mobileMoreOverlay.mobile-more-overlay{
    z-index:5000!important;
    padding-bottom:calc(70px + env(safe-area-inset-bottom))!important;
    box-sizing:border-box!important;
  }
  #mobileMoreOverlay .mobile-more-sheet{
    max-height:calc(100dvh - 92px - env(safe-area-inset-bottom))!important;
    padding-bottom:18px!important;
    overscroll-behavior:contain;
  }
  #mobilePersistentTabs.foreman-five-tabs{
    z-index:120!important;
  }
}


/* ===== Строй ОС v21.87 — mobile: object documents ===== */
@media(max-width:768px){
 .object-document-card{grid-template-columns:48px minmax(0,1fr);padding:13px}
 .object-document-icon{width:44px;height:44px;border-radius:12px;font-size:10px}
 .object-document-actions{grid-column:1/-1;display:grid;grid-template-columns:1fr 1fr}
 .object-document-actions button{width:100%;min-height:42px}
 .object-documents-head{align-items:stretch}
 .object-documents-head .btn{width:100%}
}
@media(max-width:700px){#stages .tasks-head{align-items:flex-start}.stage-head-actions{width:100%}.stage-head-actions button{flex:1}.stage-object-summary{padding:16px}.stage-object-summary b{font-size:18px}.stage-progress-ring{width:70px;height:70px;flex:0 0 70px}.stages-timeline{margin-inline:-14px;padding-inline:14px}.stage-timeline-step{min-width:118px;font-size:12px}.stage-card{grid-template-columns:38px 1fr}.stage-card-main{padding:14px 12px}.stage-card-head h2{font-size:18px}.stage-card-head .btn-light{padding:7px 9px;font-size:12px}.stage-card-actions{display:grid;grid-template-columns:1fr 1fr}.stage-card-actions button:first-child{grid-column:1/-1}.stage-editor-box,.stage-template-box,.stage-links-box{width:100%;max-height:92vh}.object-card-tabs{overflow-x:auto;justify-content:flex-start}.object-card-tabs button{white-space:nowrap}}

@media(max-width:700px){
 #stages .stage-object-summary{padding:12px!important;border-radius:16px!important;gap:10px!important;margin-bottom:12px!important}
 #stages .stage-object-summary>div:first-child{gap:2px!important}
 #stages .stage-object-summary>div:first-child b{font-size:17px!important;line-height:1.12!important}
 #stages .stage-object-summary>div:first-child small{font-size:11px!important;line-height:1.2!important}
 #stages .stage-object-kpis{gap:5px!important}
 #stages .stage-object-kpis span{padding:6px 7px!important;border-radius:9px!important;font-size:9px!important;line-height:1.15!important}
 #stages .stage-object-kpis b{font-size:13px!important}
 #stages .stage-progress-ring{width:58px!important;height:58px!important;flex-basis:58px!important}
 #stages .stage-progress-ring b{font-size:16px!important}
 #stages .stage-progress-ring span{font-size:9px!important}
}

/* v23.52: одинаковая мобильная компоновка для карточек этапов во всех
   представлениях, включая текущие работы внутри карточки объекта. */
@media(max-width:700px){
  .stage-card-head{display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:10px!important;min-width:0!important}
  .stage-card-head>div{width:100%!important;min-width:0!important}
  .stage-card-head h2{font-size:18px!important;line-height:1.15!important;overflow-wrap:break-word!important;word-break:normal!important;hyphens:none!important}
  .stage-card-head>.btn-light{grid-column:1!important;width:100%!important;min-width:0!important;justify-self:stretch!important}
}
@media(max-width:700px){.stage-dashboard-card{grid-template-columns:1fr auto}.stage-dashboard-progress{grid-column:1/-1;grid-row:2}.stage-dashboard-card>button{grid-column:2;grid-row:1}}
@media(max-width:700px){.stage-auto-button{flex-basis:100%!important}.auto-stage-row{grid-template-columns:auto 30px 1fr}.auto-stage-row>button{grid-column:3;text-align:left;padding:4px 0}.auto-stage-row>em{grid-column:2/-1}.auto-stages-summary{display:grid}}

/* ===== Строй ОС v22.61-stages — mobile stages containment ===== */
@media(max-width:700px){
  #stages.view{display:none;width:100%!important;max-width:100%!important;min-width:0!important;overflow-x:hidden!important;padding-inline:14px!important}
  #stages.view.active{display:block!important}
  #stages>.object-return-button{max-width:100%}
  #stages>.object-card-tabs{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr))!important;width:100%!important;max-width:100%!important;overflow:visible!important}
  #stages>.object-card-tabs>button{min-width:0!important;width:auto!important;padding:8px 2px!important;white-space:normal!important;font-size:10.5px!important;line-height:1.15!important}
  #stages>.tasks-head{display:grid!important;grid-template-columns:minmax(0,1fr)!important;width:100%!important;gap:14px!important}
  #stages>.tasks-head>div,#stages>.tasks-head h1,#stages>.tasks-head .small{min-width:0!important;max-width:100%!important;width:auto!important}
  #stages>.tasks-head h1{font-size:34px!important;line-height:1.02!important}
  #stages>.tasks-head .small{font-size:15px!important;line-height:1.45!important}
  #stages .stage-head-actions{display:grid!important;grid-template-columns:1fr 1fr!important;width:100%!important;min-width:0!important;gap:10px!important}
  #stages .stage-head-actions .stage-auto-button{grid-column:1/-1!important;width:100%!important;min-width:0!important;white-space:normal!important}
  #stages .stage-head-actions button{width:100%!important;min-width:0!important;white-space:normal!important}
  #stages .stage-object-summary{width:100%!important;max-width:100%!important;min-width:0!important;overflow:hidden!important}
  #stages .stages-timeline{width:calc(100% + 28px)!important;max-width:none!important;margin-inline:-14px!important;padding-inline:14px!important;overflow-x:auto!important;overflow-y:hidden!important;overscroll-behavior-x:contain}
  #stages .stages-list{display:grid!important;grid-template-columns:minmax(0,1fr)!important;width:100%!important;max-width:100%!important;min-width:0!important;gap:14px!important;overflow:visible!important;margin-top:4px!important}
  #stages .stages-list>.stage-card{display:grid!important;width:100%!important;max-width:100%!important;min-width:0!important;grid-template-columns:36px minmax(0,1fr)!important;visibility:visible!important;opacity:1}
  #stages .stage-card.blocked{opacity:.84}
  #stages .stage-card-main,#stages .stage-card-head,#stages .stage-meta,#stages .stage-linked,#stages .stage-card-actions{min-width:0!important;max-width:100%!important}
  /* На узком экране заголовок этапа не делим с кнопкой: название занимает
     всю ширину, а действие располагается отдельной строкой ниже. Это
     предотвращает разрыв слов вроде «Электрика» на несколько строк. */
  #stages .stage-card-head{display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:10px!important}
  #stages .stage-card-head>div{min-width:0!important;width:100%!important}
  #stages .stage-card-head h2{overflow-wrap:break-word;word-break:normal;hyphens:none}
  #stages .stage-card-head>.btn-light{width:100%!important;min-width:0!important;justify-self:stretch!important}
  #stages .stage-card-actions{grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important}
  #aiForemanFab.ai-foreman-fab{width:64px!important;height:64px!important;min-width:64px!important;min-height:64px!important;max-width:64px!important;max-height:64px!important;right:12px!important;bottom:calc(18px + env(safe-area-inset-bottom))!important}
  #aiForemanFab .ai-foreman-fab-icon{width:42px!important;height:42px!important}
}

/* v23.56: final narrow-screen correction for the object summary. */
@media(max-width:700px){#stages .stage-object-summary{position:relative!important;display:grid!important;grid-template-columns:minmax(0,1fr)!important;padding:12px!important;gap:8px!important;overflow:hidden!important}#stages .stage-object-summary>div:first-child{min-width:0!important;padding-right:78px!important}#stages .stage-object-summary>div:first-child b{display:block!important;max-width:100%!important;overflow-wrap:anywhere!important;word-break:normal!important}#stages .stage-progress-ring{left:auto!important;right:12px!important;top:12px!important;width:62px!important;height:62px!important;flex:none!important}}
@media(max-width:430px){#stages .stage-object-summary{padding-top:12px!important}}
