/* ==================== BASE ==================== */

dialog{background:var(--bg-elev-3);color:var(--text);
       border:1px solid var(--border);border-radius:var(--r-lg);
       width:92%;max-width:580px;padding:24px;max-height:90vh;
       overflow-y:auto;box-shadow:var(--shadow-lg);
       max-height: calc(90vh - var(--safe-top) - var(--safe-bottom));
}
dialog::backdrop{background:rgba(20,20,22,0.4);
                 backdrop-filter:blur(4px);
                 -webkit-backdrop-filter:blur(4px)}
dialog h3{margin:0 0 18px;font-size:18px;font-weight:600;
          color:var(--text);letter-spacing:-0.3px}
dialog label{display:block;font-size:12px;color:var(--text-muted);
             margin:16px 0 6px;font-weight:500;letter-spacing:-0.05px}
dialog textarea,dialog input[type=text],
dialog select,dialog input[type=datetime-local],dialog input[type=number]{
     width:100%;background:var(--bg);color:var(--text);
     border:1px solid var(--border);border-radius:var(--r-md);
     padding:11px 13px;font:15px inherit;outline:none;
     transition:border-color .15s, box-shadow .15s;
     font-family:inherit;letter-spacing:-0.1px}
dialog textarea{min-height:120px;resize:vertical;line-height:1.5}
dialog textarea:focus,dialog input:focus,dialog select:focus{
     border-color:var(--green);
     box-shadow:0 0 0 3px rgba(45,134,89,0.12)}

.actions{display:flex;gap:10px;margin-top:20px;flex-wrap:wrap}
.actions button{padding:10px 18px;border-radius:var(--r-md);border:0;
     background:var(--bg-elev-4);color:var(--text);font-size:14px;
     cursor:pointer;flex:1;min-width:100px;font-weight:500;
     letter-spacing:-0.1px;min-height:44px;
     transition:background .15s, transform .08s}
.actions button:hover{background:var(--border)}
.actions button:active{transform:scale(.98)}
.actions button.primary{background:var(--green);color:#fff;font-weight:600}
.actions button.primary:hover{background:var(--green-hover)}
.actions button.danger{background:#fdecec;color:var(--red);font-weight:600}
.actions button.danger:hover{background:#fadcdc}
.actions button:disabled{opacity:.5;cursor:default}

.option{margin-bottom:8px;text-align:left;width:100%;
        padding:14px 16px;background:var(--bg);
        color:var(--text);border:1px solid var(--border-soft);
        border-radius:var(--r-md);cursor:pointer;font-size:14px;
        font-family:inherit;min-height:44px;
        transition:background .15s, border-color .15s}
.option:hover{background:var(--bg-elev-4);border-color:var(--border)}
.opt-line{font-size:12px;color:var(--text-dim);margin-top:6px;
          line-height:1.5}

.readonly-block{margin-top:14px;padding:14px 16px;
  background:var(--bg);border-radius:var(--r-md);
  border:1px solid var(--border-soft)}
.readonly-block.hidden{display:none}
.ro-label{font-size:11px;color:var(--text-muted);margin-bottom:8px;
          font-weight:600;letter-spacing:.2px;text-transform:uppercase}
.ro-text{font-size:14px;color:var(--text);line-height:1.6;
         white-space:pre-wrap;word-wrap:break-word;
         letter-spacing:-0.1px}
.ro-raw{font-style:italic;color:var(--text-muted);font-size:13px}

.from-block{background:var(--blue-bg);border-color:#d3e4f7}
.from-block .ro-label{color:var(--blue)}
.from-block .ro-text{color:#1a4a8a}

#blockTransferInfo{
  background: var(--orange-bg);
  border-color: #f0d9b8;
}
#blockTransferInfo .ro-label{ color: var(--orange); }
#blockTransferInfo .ro-text{ color: #7a4514; }

.checkbox-label{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  user-select: none;
  transition: background .15s, border-color .15s;
  flex-wrap: wrap;
  min-height: 44px;
}
.checkbox-label:hover{
  background: var(--bg-elev-4);
  border-color: var(--border);
}
.checkbox-label input[type=checkbox]{
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}
.checkbox-label > span:first-of-type{ font-weight: 500; }
.checkbox-hint{
  font-size: 11.5px;
  color: var(--text-dim);
  width: 100%;
  padding-left: 26px;
  margin-top: -2px;
  letter-spacing: -0.05px;
  line-height: 1.4;
}

.dialog-tabs{
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-soft);
  margin: -8px -24px 16px -24px;
  padding: 0 24px;
}
.dialog-tab{
  padding: 10px 14px;
  background: transparent;
  color: var(--text-muted);
  border: 0;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.1px;
  transition: color .15s, border-color .15s;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 44px;
}
.dialog-tab:hover{ color: var(--text) }
.dialog-tab.active{
  color: var(--green);
  border-bottom-color: var(--green);
}
.dialog-tabs.hidden{ display: none }

.dialog-panel.hidden{ display: none }

.checklist-list{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.checklist-row{
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.checklist-item{
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  transition: background .15s, border-color .15s;
}
.checklist-row:hover .checklist-item{
  background: var(--bg-elev-4);
  border-color: var(--border);
}

.checklist-item input[type=checkbox]{
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--green);
  cursor: pointer;
  margin-right: 10px;
  margin-top: 3px;
}

.checklist-item .cl-text{
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  padding: 2px 0;
  border: 0;
  background: transparent;
  outline: none;
  cursor: text;
  border-radius: 0;
}
.checklist-item .cl-text:focus{
  background: transparent;
  box-shadow: none;
  outline: none;
}
.checklist-item.done .cl-text{
  text-decoration: line-through;
  color: var(--text-muted);
}

.checklist-row .cl-del{
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-dim);
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background .15s, color .15s, opacity .15s;
  font-family: inherit;
  flex: 0 0 auto;
  min-width: 0;
  margin-top: 6px;
  padding: 0;
  opacity: 0.35;
}
.checklist-row:hover .cl-del{ opacity: 1 }
.checklist-row .cl-del:hover{
  background: var(--red-bg);
  color: var(--red);
}

.checklist-add{
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.checklist-add input{
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font: 14px inherit;
  outline: none;
  font-family: inherit;
  min-height: 44px;
}
.checklist-add input:focus{
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45,134,89,0.12);
}
.checklist-add button{
  padding: 9px 16px;
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: background .15s;
  white-space: nowrap;
  flex: 0 0 auto;
  min-height: 44px;
}
.checklist-add button:hover{ background: var(--green-hover) }

.checklist-empty{
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 24px 12px;
  line-height: 1.6;
}

.checklist-progress{
  display: inline-block;
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

.btn-add-checklist{
  width: 100%;
  padding: 11px;
  background: var(--bg-elev-4);
  color: var(--text);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: background .15s, border-color .15s;
  min-height: 44px;
}
.btn-add-checklist:hover{
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}
.btn-add-checklist.hidden{ display: none }

.event-datetime{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
dialog .hidden{ display: none !important; }

.color-row{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.color-swatch{
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .1s, border-color .15s;
}
.color-swatch:hover{ transform: scale(1.08); }
.color-swatch.selected{
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg-elev-3);
}

.dialog-header{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-bottom: 12px;
  text-align: center;
}

.dialog-header h3{
  margin: 0;
  width: 100%;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
  text-align: center;
}

.dialog-header-actions{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.btn-complete{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-elev-4);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.1px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 40px;
  transition: background .15s, color .15s, border-color .15s, transform .08s;
}
.btn-complete:hover{
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green);
}
.btn-complete:active{ transform: scale(.97); }
.btn-complete:disabled{ opacity: .5; cursor: default; }
.btn-complete-icon{ font-size: 14px; line-height: 1; }
.btn-complete-label{ line-height: 1; }
.btn-complete.is-done{
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green);
}
.btn-complete.is-done:hover{
  background: var(--bg-elev-4);
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-share,
.btn-take,
.btn-transfer,
.btn-return,
.btn-merge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-elev-4);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.1px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 40px;
  transition: background .15s, color .15s, border-color .15s, transform .08s;
}
.btn-share:hover{
  background: var(--blue-bg);
  color: var(--blue);
  border-color: var(--blue);
}
.btn-take:hover{
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green);
}
.btn-transfer:hover{
  background: var(--orange-bg);
  color: var(--orange);
  border-color: var(--orange);
}
.btn-return:hover{
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red);
}
.btn-merge:hover{
  background: var(--purple-bg);
  color: var(--purple);
  border-color: var(--purple);
}
.btn-share:active,
.btn-take:active,
.btn-transfer:active,
.btn-return:active,
.btn-merge:active{ transform: scale(.97); }
.btn-share:disabled,
.btn-take:disabled,
.btn-transfer:disabled,
.btn-return:disabled,
.btn-merge:disabled{ opacity: .5; cursor: default; }
.btn-share.hidden,
.btn-take.hidden,
.btn-transfer.hidden,
.btn-return.hidden,
.btn-merge.hidden{ display: none; }
.btn-share-icon,
.btn-take-icon,
.btn-transfer-icon,
.btn-return-icon,
.btn-merge-icon{ font-size: 14px; line-height: 1; }

/* ==================== МУЛЬТИНАЗНАЧЕНИЕ ==================== */

.assign-row{ margin-top: 16px; position: relative; }
.assign-row.hidden{ display: none; }
.assign-row label{
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 6px;
  font-weight: 500;
  letter-spacing: -0.05px;
}

.assign-trigger{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 11px 13px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font: 15px inherit;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  text-align: left;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.assign-trigger:hover{ background: var(--bg-elev-4); }
.assign-trigger.open{
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45,134,89,0.12);
}
.assign-trigger-label{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.assign-trigger-caret{
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  transition: transform .15s;
}
.assign-trigger.open .assign-trigger-caret{
  transform: rotate(180deg);
}

.assignee-popup{
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-height: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.assignee-popup.hidden{ display: none; }

.assignee-popup-title{
  padding: 10px 14px 6px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}

.assignee-popup-list{
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px;
}

.assignee-popup-empty{
  padding: 14px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.assignee-popup-item{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
  transition: background .12s;
  font-size: 14px;
  color: var(--text);
  min-height: 44px;
}
.assignee-popup-item:hover{ background: var(--bg-elev-4); }
.assignee-popup-item.checked{ background: var(--green-bg); color: var(--green); }
.assignee-popup-item input[type=checkbox]{
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--green);
  cursor: pointer;
  margin: 0;
}
.assignee-popup-name{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assignee-popup-me{
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
}

.assignee-popup-hint{
  padding: 8px 14px;
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.45;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-elev-4);
}
.assignee-popup-hint b{ color: var(--text); }

.assignee-popup-actions{
  padding: 8px 14px 10px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  background: var(--bg-elev-4);
}
.assignee-popup-actions .btn-sm{
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--r-sm);
  min-height: 40px;
}
.assignee-popup-actions .btn-sm.hidden{ display: none; }

.task-space-badge.multi{
  background: var(--purple-bg);
  color: var(--purple);
  padding: 2px 6px;
  gap: 3px;
}
.task-space-badge.multi .multi-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.task-space-badge.multi .multi-icon svg{
  width: 13px;
  height: 13px;
  display: block;
}
.task-space-badge.multi .multi-count{
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* ==================== ВЛОЖЕНИЯ В ОКНЕ ВВОДА ==================== */

.input-field-wrap{
  position: relative;
}

.input-field-wrap textarea{
  padding-right: 52px;
}

.input-attach-btn{
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev-4);
  color: var(--text-muted);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s, color .15s, transform .08s;
  padding: 0;
}
.input-attach-btn:hover{
  background: var(--green-bg);
  color: var(--green);
}
.input-attach-btn:active{
  transform: scale(.94);
}
.input-attach-btn svg{
  display: block;
}

.input-attach-menu{
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  padding: 4px;
  background: var(--bg-elev-4);
  border-radius: var(--r-md);
  width: 100%;
}
.input-attach-menu.hidden{
  display: none;
}

.attach-menu-item{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  min-height: 44px;
  transition: background .15s;
}
.attach-menu-item:hover{
  background: var(--bg-elev-2);
}
.attach-menu-item svg{
  flex-shrink: 0;
  color: var(--green);
}

.input-attach-strip{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
}
.input-attach-strip.hidden{
  display: none;
}

.attach-strip-thumbs{
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.attach-thumb{
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-elev-4);
}

.attach-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-thumb-remove{
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20,20,22,0.7);
  color: #fff;
  border: 0;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.attach-thumb-remove:hover{
  background: var(--red);
}

.attach-strip-info{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.attach-strip-clear{
  background: transparent;
  color: var(--text-muted);
  border: 0;
  font-size: 11.5px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
}
.attach-strip-clear:hover{ color: var(--red); }

.input-hint{
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.4;
  letter-spacing: -0.05px;
}

/* ==================== БЛОК ФОТО В ДЕТАЛЯХ ==================== */

.details-attach{
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
}
.details-attach.hidden{ display: none; }

.details-attach-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.details-attach-title{
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.1px;
}

.details-attach-count{
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-dim);
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}

.details-attach-actions{
  display: flex;
  gap: 6px;
}

.details-attach-btn{
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: var(--bg-elev-4);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 40px;
  transition: background .15s, color .15s, border-color .15s;
}
.details-attach-btn:hover{
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green);
}
.details-attach-btn svg{ display: block; }

.details-attach-body{
  position: relative;
}

.details-attach-body.drag-over{
  outline: 2px dashed var(--green);
  outline-offset: 4px;
  border-radius: var(--r-md);
}

.details-attach-empty{
  padding: 16px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--bg-elev-4);
  border-radius: var(--r-md);
}
.details-attach-empty.hidden{ display: none; }
.details-attach-empty b{ color: var(--text-muted); }

.details-attach-thumbs{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.details-thumb{
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-elev-4);
  cursor: pointer;
  flex-shrink: 0;
}

.details-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .15s;
}
.details-thumb:hover img{
  transform: scale(1.05);
}

.details-thumb-remove{
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20,20,22,0.7);
  color: #fff;
  border: 0;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.details-thumb:hover .details-thumb-remove{ opacity: 1; }
.details-thumb-remove:hover{ background: var(--red); }

.details-thumb.loading::after{
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.details-thumb.loading::before{
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 2;
}

@keyframes spin{
  to { transform: rotate(360deg); }
}

/* ==================== ЛАЙТБОКС ==================== */

dialog.lightbox{
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  margin: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

dialog.lightbox::backdrop{
  background: rgba(10,10,12,0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

dialog.lightbox:not([open]){
  display: none;
}

.lightbox-stage{
  position: relative;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.lightbox-img{
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--r-md);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: block;
  background: #111;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next{
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, transform .08s;
  z-index: 2;
}

.lightbox-close{
  top: calc(20px + var(--safe-top));
  right: calc(20px + var(--safe-right));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
}
.lightbox-close:hover{ background: rgba(255,255,255,0.22); }
.lightbox-close:active{ transform: scale(.94); }

.lightbox-prev,
.lightbox-next{
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 32px;
  line-height: 1;
  padding-bottom: 4px;
}
.lightbox-prev{ left: calc(20px + var(--safe-left)); }
.lightbox-next{ right: calc(20px + var(--safe-right)); }
.lightbox-prev:hover,
.lightbox-next:hover{ background: rgba(255,255,255,0.22); }
.lightbox-prev:active,
.lightbox-next:active{ transform: translateY(-50%) scale(.94); }
.lightbox-prev.hidden,
.lightbox-next.hidden{ display: none; }

.lightbox-counter{
  position: absolute;
  bottom: calc(22px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: 6px 14px;
  background: rgba(0,0,0,0.35);
  border-radius: 16px;
  letter-spacing: -0.1px;
}
.lightbox-counter.hidden{ display: none; }

/* ==================== ПОИСК Ctrl+K ==================== */

dialog.search-dialog{
  width: 92%;
  max-width: 640px;

  height: 70vh;
  min-height: 380px;
  max-height: 600px;

  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);

  margin: 8vh auto auto;
}

dialog.search-dialog::backdrop{
  background: rgba(20,20,22,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

dialog.search-dialog:not([open]){ display: none; }

.search-dialog-head{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.search-dialog-icon{
  flex-shrink: 0;
  color: var(--text-dim);
}

.search-dialog-head input{
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  padding: 4px 0;
  letter-spacing: -0.1px;
}
.search-dialog-head input::placeholder{
  color: var(--text-dim);
}

.search-dialog-close{
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.search-dialog-close:hover{ background: var(--bg-elev-4); color: var(--text); }

.search-dialog-body{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.search-empty{
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13.5px;
}
.search-empty.hidden{ display: none; }

.search-hint{
  position: sticky;
  bottom: 0;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-elev-4);
  border-top: 1px solid var(--border-soft);
  text-align: center;
}
.search-hint.hidden{ display: none; }

.search-results{
  padding: 6px;
}

.search-item{
  padding: 9px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .12s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 44px;
}
.search-item:hover{ background: var(--bg-elev-4); }
.search-item.active{ background: var(--green-bg); }

.search-item-title{
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
  letter-spacing: -0.1px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.search-item.active .search-item-title{ color: var(--green-hover); }

.search-item-meta{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-dim);
}

.search-item-meta .search-cat{
  padding: 2px 7px;
  background: var(--bg-elev-4);
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.search-item-meta .search-from{
  color: var(--blue);
  background: var(--blue-bg);
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-item-meta .search-due{
  color: var(--blue);
  background: var(--blue-bg);
  padding: 2px 7px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.search-item-meta .search-due.overdue{
  color: var(--red);
  background: var(--red-bg);
}

.search-item-meta .search-done{
  color: var(--green);
  font-weight: 700;
  margin-right: 4px;
}

.search-item .task-space-badge{
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  white-space: nowrap;
}

.search-item-meta .search-dept{
  color: var(--purple);
  background: var(--purple-bg);
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
  font-size: 10.5px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-dialog-foot{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-elev-4);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.search-kbd-hint{
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.search-kbd-hint kbd{
  display: inline-block;
  padding: 1px 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==================== СПРАВКА / ГОРЯЧИЕ КЛАВИШИ ==================== */

dialog.help-dialog{
  width: 92%;
  max-width: 520px;
  max-height: 82vh;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  margin: 8vh auto auto;
}

dialog.help-dialog::backdrop{
  background: rgba(20,20,22,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

dialog.help-dialog:not([open]){ display: none; }

.help-dialog-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.help-dialog-head h3{
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
}

.help-dialog-close{
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.help-dialog-close:hover{ background: var(--bg-elev-4); color: var(--text); }

.help-dialog-body{
  padding: 14px 20px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.help-section{
  margin-bottom: 20px;
}
.help-section:last-child{ margin-bottom: 0; }

.help-section-title{
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}

.help-list{
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.help-row{
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr;
  gap: 16px;
  align-items: center;
  padding: 8px 4px;
  border-radius: var(--r-sm);
  transition: background .12s;
}
.help-row:hover{ background: var(--bg-elev-4); }

.help-keys{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  white-space: nowrap;
}

.help-keys kbd{
  display: inline-block;
  min-width: 22px;
  padding: 3px 8px;
  background: var(--bg-elev-4);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
}

.help-plus,
.help-alt{
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 2px;
  font-weight: 500;
}

.help-desc{
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.4;
  text-align: right;
  letter-spacing: -0.05px;
}

/* ==================== КОРЗИНА ==================== */

#btnTrash{
  position: relative;
}
.trash-badge{
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--red);
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--bg-elev-1);
}
.trash-badge.hidden{ display: none; }

dialog.trash-dialog{
  width: 92%;
  max-width: 720px;
  height: 70vh;
  min-height: 380px;
  max-height: 640px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  margin: 8vh auto auto;
}
dialog.trash-dialog::backdrop{
  background: rgba(20,20,22,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
dialog.trash-dialog:not([open]){ display: none; }

.trash-dialog-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.trash-dialog-head h3{
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
}

.trash-dialog-close{
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.trash-dialog-close:hover{ background: var(--bg-elev-4); color: var(--text); }

.trash-dialog-hint{
  margin: 0;
  padding: 8px 20px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  background: var(--bg-elev-4);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.trash-dialog-body{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}

.trash-dialog-foot{
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-elev-4);
  flex-shrink: 0;
}

.trash-loading{
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.trash-empty{
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
}
.trash-empty-icon{
  font-size: 40px;
  opacity: .35;
  margin-bottom: 14px;
}
.trash-empty-title{
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.trash-empty-hint{
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

.trash-item{
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  transition: background .15s, border-color .15s;
}
.trash-item:hover{
  background: var(--bg-elev-4);
  border-color: var(--border);
}

.trash-item-main{
  flex: 1;
  min-width: 0;
}

.trash-item-title{
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.1px;
  line-height: 1.35;
  margin-bottom: 6px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.trash-item-meta{
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-dim);
}

.trash-age{
  color: var(--text-muted);
  font-weight: 500;
}
.trash-days-left{
  padding: 1px 7px;
  background: var(--red-bg);
  color: var(--red);
  border-radius: 10px;
  font-weight: 500;
  font-size: 10.5px;
}

.trash-cat,
.trash-from{
  padding: 2px 7px;
  background: var(--bg-elev-4);
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trash-from{
  background: var(--blue-bg);
  color: var(--blue);
}

.trash-item-meta .due-badge{
  font-size: 10.5px;
  padding: 2px 7px;
  margin: 0;
}

.trash-item-actions{
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.trash-btn{
  padding: 7px 12px;
  background: var(--bg-elev-4);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 40px;
  transition: background .15s, color .15s, border-color .15s;
}
.trash-btn:hover{
  background: var(--border);
  color: var(--text);
}
.trash-btn.primary{
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green);
}
.trash-btn.primary:hover{
  background: var(--green);
  color: #fff;
}
.trash-btn.danger{
  background: var(--bg-elev-4);
  color: var(--red);
  border-color: var(--border-soft);
}
.trash-btn.danger:hover{
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.trash-btn:disabled{
  opacity: .5;
  cursor: default;
}
.trash-dialog-foot .trash-btn.danger{
  padding: 8px 14px;
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red);
}
.trash-dialog-foot .trash-btn.danger:hover{
  background: var(--red);
  color: #fff;
}

/* ==================== МОДАЛКА «ЕЩЁ» ==================== */

dialog.more-sheet-dialog{
  width: 90%;
  max-width: 360px;
  max-height: 80vh;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev-3);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

dialog.more-sheet-dialog::backdrop{
  background: rgba(20,20,22,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

dialog.more-sheet-dialog:not([open]){
  display: none;
}

.more-sheet-grabber{
  display: none;
}

.more-sheet-body{
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  overflow-y: auto;
}

.more-item{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: transparent;
  color: var(--text);
  border: 0;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  min-height: 56px;
  transition: background .12s;
  position: relative;
}

.more-item:hover{
  background: var(--bg-elev-4);
}

.more-item:active{
  background: var(--border-soft);
}

.more-item-icon{
  font-size: 20px;
  line-height: 1;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.more-item-label{
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.1px;
}

.more-item-badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--red);
  color: #fff;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.more-item-badge.hidden{
  display: none;
}

.more-item.danger{
  color: var(--red);
  border-top: 1px solid var(--border-soft);
  margin-top: 6px;
  padding-top: 16px;
}

.more-item.danger .more-item-icon{
  color: var(--red);
}

.more-item.hidden{
  display: none;
}

/* ==================== C.3b: кнопки-тумблеры ==================== */

.btn-flag{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s, transform .08s;
  outline: none;
}

.btn-flag:hover{
  background: var(--bg-elev-4);
  color: var(--text);
}

.btn-flag:active{
  transform: scale(.92);
}

.btn-flag:focus,
.btn-flag:focus-visible{
  outline: none;
  box-shadow: none;
}

.btn-flag.active{
  background: var(--orange-bg);
  color: var(--orange);
  border: 0;
}

.btn-flag.active.btn-flag-important{
  background: #fff8e1;
  color: #c9a227;
  border: 0;
}

.btn-flag-icon{
  font-size: 18px;
  line-height: 1;
  filter: grayscale(1);
  opacity: 0.55;
  transition: filter .15s, opacity .15s;
}

.btn-flag:hover .btn-flag-icon{
  opacity: 0.85;
}

.btn-flag.active .btn-flag-icon{
  filter: grayscale(0);
  opacity: 1;
}

/* ==================== C.3b-fix-3: раскладка шапки ==================== */

.dialog-header-actions{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.dialog-header-actions .btn-merge,
.dialog-header-actions .btn-transfer,
.dialog-header-actions .btn-return,
.dialog-header-actions .btn-share,
.dialog-header-actions .btn-take,
.dialog-header-actions .btn-complete{
  padding: 6px 10px;
  min-height: 34px;
  font-size: 12px;
  gap: 4px;
}

.dialog-header-actions .btn-merge-icon,
.dialog-header-actions .btn-transfer-icon,
.dialog-header-actions .btn-return-icon,
.dialog-header-actions .btn-share-icon,
.dialog-header-actions .btn-take-icon,
.dialog-header-actions .btn-complete-icon{
  font-size: 13px;
  line-height: 1;
}

/* На широком экране даём больше места под кнопки */
@media (min-width: 641px){
  dialog#dlgDetails{
    max-width: 680px;
  }
}

/* ==================== C.3b-fix-6: палитра — position относительно диалога ==================== */

.color-popup{
  position: absolute;
  top: 130px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  min-width: 260px;
  max-width: calc(100% - 32px);
}

.color-popup.hidden{
  display: none;
}

.color-popup-title{
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 8px;
  padding: 0 2px;
}

.color-popup-swatches{
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.color-swatch-item{
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform .1s, border-color .15s;
}

.color-swatch-item:hover{
  transform: scale(1.1);
}

.color-swatch-item.selected{
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg-elev-2);
}

.color-swatch-item.no-color{
  background: var(--bg);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
}

.color-swatch-item.no-color::after{
  content: '✕';
  font-size: 12px;
  font-weight: 700;
}

/* ==================== Мобильный ==================== */

@media (max-width: 640px){
  dialog{
    padding:18px;
    width:94%;
    padding-bottom: calc(18px + var(--safe-bottom));
  }
  .dialog-tabs{margin-left:-18px;margin-right:-18px;padding-left:18px;padding-right:18px}
  .checklist-row .cl-del{
    width: 44px;
    height: 44px;
    font-size: 18px;
    margin-top: 0;
    opacity: 1;
  }
  .attach-menu-item{
    padding: 14px 16px;
    font-size: 15px;
  }
  .input-attach-btn{
    width: 44px;
    height: 44px;
  }
  .details-thumb{
    width: 64px;
    height: 64px;
  }
  .details-thumb-remove{
    opacity: 1;
    width: 26px;
    height: 26px;
    font-size: 16px;
  }
  .details-attach-btn{
    padding: 8px 12px;
    font-size: 13px;
    min-height: 44px;
  }
  .lightbox-prev,
  .lightbox-next{
    width: 44px;
    height: 44px;
    font-size: 26px;
  }
  .lightbox-close{
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
  dialog.search-dialog{
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    min-height: 0;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }
  .search-dialog-head{ padding: 12px 14px; }
  .search-dialog-head input{ font-size: 15px; }
  .search-dialog-close{
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  .search-item{ padding: 12px 14px; }
  .search-dialog-foot{ display: none; }
  dialog.help-dialog{
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    margin: 0;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }
  .help-row{
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .help-desc{
    text-align: left;
    font-size: 13px;
  }
  .help-dialog-close{
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  dialog.trash-dialog{
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }
  .trash-dialog-close{
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  .trash-item{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .trash-item-actions{
    justify-content: flex-end;
  }
  .trash-btn{
    min-height: 44px;
    padding: 10px 14px;
    font-size: 13px;
  }

  .dialog-header{
    gap: 8px;
    margin-bottom: 12px;
  }

  .dialog-header-actions{
    flex-wrap: nowrap;
    justify-content: center;
    gap: 4px;
  }

  .btn-flag{
    width: 32px;
    height: 32px;
    background: transparent;
    border: 0;
    color: var(--text-muted);
  }

  .btn-flag:hover,
  .btn-flag:focus,
  .btn-flag:focus-visible{
    background: transparent;
    border: 0;
    outline: none;
    box-shadow: none;
  }

  .btn-flag.active{
    background: transparent;
    border: 0;
    color: var(--orange);
  }

  .btn-flag.active.btn-flag-important{
    background: transparent;
    border: 0;
    color: #c9a227;
  }

  .btn-flag-icon{
    font-size: 20px;
  }

  .btn-flag + .btn-merge,
  .btn-flag + .btn-transfer,
  .btn-flag + .btn-return,
  .btn-flag + .btn-share,
  .btn-flag + .btn-take,
  .btn-flag + .btn-complete{
    margin-left: 10px;
    position: relative;
  }

  .btn-flag + .btn-merge::before,
  .btn-flag + .btn-transfer::before,
  .btn-flag + .btn-return::before,
  .btn-flag + .btn-share::before,
  .btn-flag + .btn-take::before,
  .btn-flag + .btn-complete::before{
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 20px;
    background: var(--border-soft);
  }

  .dialog-header-actions .btn-merge,
  .dialog-header-actions .btn-transfer,
  .dialog-header-actions .btn-return,
  .dialog-header-actions .btn-share,
  .dialog-header-actions .btn-take,
  .dialog-header-actions .btn-complete{
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    border-radius: 50%;
    gap: 0;
    justify-content: center;
    align-items: center;
  }

  .dialog-header-actions .btn-merge-label,
  .dialog-header-actions .btn-transfer-label,
  .dialog-header-actions .btn-return-label,
  .dialog-header-actions .btn-share-label,
  .dialog-header-actions .btn-take-label,
  .dialog-header-actions .btn-complete-label{
    display: none;
  }

  .dialog-header-actions .btn-merge-icon,
  .dialog-header-actions .btn-transfer-icon,
  .dialog-header-actions .btn-return-icon,
  .dialog-header-actions .btn-share-icon,
  .dialog-header-actions .btn-take-icon,
  .dialog-header-actions .btn-complete-icon{
    font-size: 18px;
    line-height: 1;
  }

  .color-popup{
    top: 130px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 260px;
    max-width: calc(100vw - 32px);
  }

  .color-popup-swatches{
    grid-template-columns: repeat(6, 1fr);
  }

  .color-swatch-item{
    width: 30px;
    height: 30px;
  }

  dialog.more-sheet-dialog{
    width: 88%;
    max-width: 340px;
    max-height: 75vh;
  }
}

@media (max-width:500px){
  .event-datetime{ grid-template-columns: 1fr; }
  .btn-complete-label{ display: none; }
  .btn-complete{ padding: 7px 10px; min-height: 44px; }
  .dialog-header-actions{ gap: 6px; }
  .btn-share,
  .btn-take,
  .btn-transfer,
  .btn-return,
  .btn-merge{ padding: 6px 10px; min-height: 44px; }
  .btn-share-label,
  .btn-take-label,
  .btn-transfer-label,
  .btn-return-label,
  .btn-merge-label{ display: none; }
}

/* ==================== C.4: полноэкранные детали на мобильном ==================== */

/* Крестик закрытия — по умолчанию скрыт (десктоп).
   В правом верхнем углу диалога, absolute внутри dialog. */
.dlg-close-btn{
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--red);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
  padding: 0;
  z-index: 30;
  transition: color .15s, transform .08s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.dlg-close-btn:hover{
  color: var(--red);
  opacity: 0.75;
}
.dlg-close-btn:active{
  transform: scale(.92);
}
.dlg-close-btn:focus,
.dlg-close-btn:focus-visible{
  outline: none;
  box-shadow: none;
}

/* Подсказка «потяни вниз» — по умолчанию скрыта */
.dlg-take-hint{
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: -4px 0 12px;
  padding: 8px 14px;
  background: var(--green-bg);
  color: var(--green);
  border-radius: var(--r-md);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.05px;
  animation: dlgTakeHintPulse 2s ease-in-out infinite;
}
.dlg-take-hint.hidden{ display: none !important; }
.dlg-take-hint-icon{
  font-size: 14px;
  line-height: 1;
  display: inline-block;
  animation: dlgTakeHintArrow 1.6s ease-in-out infinite;
}
@keyframes dlgTakeHintArrow{
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}
@keyframes dlgTakeHintPulse{
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

/* Фантом-плашка при свайпе вниз, когда задачу нельзя взять */
.dlg-swipe-toast{
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.9);
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity .15s ease-out, transform .15s ease-out;
}
.dlg-swipe-toast.visible{
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.dlg-swipe-toast-label{
  display: inline-block;
  padding: 12px 22px;
  background: rgba(184, 58, 58, 0.88);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
}

/* C.4-fix-2: свой backdrop для dlgDetails на мобильном.
   Позволяет управлять прозрачностью во время drag. */
.dlg-backdrop{
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 22, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 5;
  opacity: 0;
  transition: opacity .28s ease-out;
  pointer-events: none;
}
.dlg-backdrop.is-visible{
  display: block;
  opacity: 1;
}
.dlg-backdrop.is-dragging{
  transition: none;
}

/* C.4-fix-2: пружина возврата + анимация закрытия для dlgDetails */
dialog#dlgDetails{
  transition: transform .28s cubic-bezier(.2, .9, .3, 1);
  will-change: transform;
}
dialog#dlgDetails.swipe-dragging{
  transition: none;
  will-change: transform;
}
dialog#dlgDetails.swipe-dismiss-right{
  transform: translateX(110%) !important;
  transition: transform .25s ease-out, opacity .25s ease-out !important;
  opacity: 0;
}
dialog#dlgDetails.swipe-dismiss-down{
  transform: translateY(110%) !important;
  transition: transform .25s ease-out, opacity .25s ease-out !important;
  opacity: 0;
}

@media (max-width: 640px){
  /* C.4: полноэкранный диалог деталей */
  dialog#dlgDetails{
    width: 100vw;
    max-width: 100vw;
    /* C.4-fix: 100dvh учитывает адресную строку мобильного браузера.
       100vh оставляем как fallback для старых браузеров. */
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--bg-elev-3);
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    overflow: hidden;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: contain;
  }

  dialog#dlgDetails:not([open]){
    display: none;
  }

  /* Свой backdrop — вместо нативного ::backdrop.
     Так можем управлять прозрачностью во время drag. */
  dialog#dlgDetails::backdrop{
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Отключаем pull-to-refresh и на скролл-контейнере внутри */
  dialog#dlgDetails > .dialog-panel,
  dialog#dlgDetails > .dialog-panel *{
    overscroll-behavior-y: contain;
  }

  dialog#dlgDetails > .dialog-header,
  dialog#dlgDetails > .color-popup,
  dialog#dlgDetails > .dialog-tabs,
  dialog#dlgDetails > .dialog-panel,
  dialog#dlgDetails > .actions{
    padding-left: 16px;
    padding-right: 16px;
  }

  dialog#dlgDetails > .dialog-header{
    padding-top: 18px;
    padding-bottom: 0;
  }

  dialog#dlgDetails > .dialog-header h3{
    padding-right: 0;
  }

  dialog#dlgDetails > .dialog-panel{
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  dialog#dlgDetails > .actions{
    padding-top: 12px;
    padding-bottom: 12px;
    background: var(--bg-elev-3);
    border-top: 1px solid var(--border-soft);
    flex-shrink: 0;
    flex-grow: 0;
    margin-top: 0;
    /* C.4-fix: кнопки всегда в потоке внизу, гарантированно видны */
    position: relative;
    z-index: 2;
  }

  /* Крестик видим на мобильном — фиксирован в правом верхнем углу */
  .dlg-close-btn{
    display: inline-flex;
    top: calc(6px + var(--safe-top));
    right: 6px;
    width: 44px;
    height: 44px;
    font-size: 28px;
  }

  /* Подсказка «потяни вниз» видна на мобильном */
  .dlg-take-hint{
    display: flex;
  }
}